OSDN Git Service

Move pg_db_role_setting docs to correct place in alphabetical order.
[pg-rex/syncrep.git] / doc / src / sgml / catalogs.sgml
1 <!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.225.2.5 2010/09/17 18:50:22 rhaas Exp $ -->
2 <!--
3  Documentation of the system catalogs, directed toward PostgreSQL developers
4  -->
5
6 <chapter id="catalogs">
7  <title>System Catalogs</title>
8
9   <para>
10    The system catalogs are the place where a relational database
11    management system stores schema metadata, such as information about
12    tables and columns, and internal bookkeeping information.
13    <productname>PostgreSQL</productname>'s system catalogs are regular
14    tables.  You can drop and recreate the tables, add columns, insert
15    and update values, and severely mess up your system that way.
16    Normally, one should not change the system catalogs by hand, there
17    are always SQL commands to do that.  (For example, <command>CREATE
18    DATABASE</command> inserts a row into the
19    <structname>pg_database</structname> catalog &mdash; and actually
20    creates the database on disk.)  There are some exceptions for
21    particularly esoteric operations, such as adding index access methods.
22   </para>
23
24  <sect1 id="catalogs-overview">
25   <title>Overview</title>
26
27   <para>
28    <xref linkend="catalog-table"> lists the system catalogs.
29    More detailed documentation of each catalog follows below.
30   </para>
31
32   <para>
33    Most system catalogs are copied from the template database during
34    database creation and are thereafter database-specific. A few
35    catalogs are physically shared across all databases in a cluster;
36    these are noted in the descriptions of the individual catalogs.
37   </para>
38
39   <table id="catalog-table">
40    <title>System Catalogs</title>
41
42    <tgroup cols="2">
43     <thead>
44      <row>
45       <entry>Catalog Name</entry>
46       <entry>Purpose</entry>
47      </row>
48     </thead>
49
50     <tbody>
51      <row>
52       <entry><link linkend="catalog-pg-aggregate"><structname>pg_aggregate</structname></link></entry>
53       <entry>aggregate functions</entry>
54      </row>
55
56      <row>
57       <entry><link linkend="catalog-pg-am"><structname>pg_am</structname></link></entry>
58       <entry>index access methods</entry>
59      </row>
60
61      <row>
62       <entry><link linkend="catalog-pg-amop"><structname>pg_amop</structname></link></entry>
63       <entry>access method operators</entry>
64      </row>
65
66      <row>
67       <entry><link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link></entry>
68       <entry>access method support procedures</entry>
69      </row>
70
71      <row>
72       <entry><link linkend="catalog-pg-attrdef"><structname>pg_attrdef</structname></link></entry>
73       <entry>column default values</entry>
74      </row>
75
76      <row>
77       <entry><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link></entry>
78       <entry>table columns (<quote>attributes</quote>)</entry>
79      </row>
80
81      <row>
82       <entry><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link></entry>
83       <entry>authorization identifiers (roles)</entry>
84      </row>
85
86      <row>
87       <entry><link linkend="catalog-pg-auth-members"><structname>pg_auth_members</structname></link></entry>
88       <entry>authorization identifier membership relationships</entry>
89      </row>
90
91      <row>
92       <entry><link linkend="catalog-pg-cast"><structname>pg_cast</structname></link></entry>
93       <entry>casts (data type conversions)</entry>
94      </row>
95
96      <row>
97       <entry><link linkend="catalog-pg-class"><structname>pg_class</structname></link></entry>
98       <entry>tables, indexes, sequences, views (<quote>relations</quote>)</entry>
99      </row>
100
101      <row>
102       <entry><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link></entry>
103       <entry>check constraints, unique constraints, primary key constraints, foreign key constraints</entry>
104      </row>
105
106      <row>
107       <entry><link linkend="catalog-pg-conversion"><structname>pg_conversion</structname></link></entry>
108       <entry>encoding conversion information</entry>
109      </row>
110
111      <row>
112       <entry><link linkend="catalog-pg-database"><structname>pg_database</structname></link></entry>
113       <entry>databases within this database cluster</entry>
114      </row>
115
116      <row>
117       <entry><link linkend="catalog-pg-db-role-setting"><structname>pg_db_role_setting</structname></link></entry>
118       <entry>per-role and per-database settings</entry>
119      </row>
120
121      <row>
122       <entry><link linkend="catalog-pg-default-acl"><structname>pg_default_acl</structname></link></entry>
123       <entry>default privileges for object types</entry>
124      </row>
125
126      <row>
127       <entry><link linkend="catalog-pg-depend"><structname>pg_depend</structname></link></entry>
128       <entry>dependencies between database objects</entry>
129      </row>
130
131      <row>
132       <entry><link linkend="catalog-pg-description"><structname>pg_description</structname></link></entry>
133       <entry>descriptions or comments on database objects</entry>
134      </row>
135
136      <row>
137       <entry><link linkend="catalog-pg-enum"><structname>pg_enum</structname></link></entry>
138       <entry>enum label and value definitions</entry>
139      </row>
140
141      <row>
142       <entry><link linkend="catalog-pg-foreign-data-wrapper"><structname>pg_foreign_data_wrapper</structname></link></entry>
143       <entry>foreign-data wrapper definitions</entry>
144      </row>
145
146      <row>
147       <entry><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link></entry>
148       <entry>foreign server definitions</entry>
149      </row>
150
151      <row>
152       <entry><link linkend="catalog-pg-index"><structname>pg_index</structname></link></entry>
153       <entry>additional index information</entry>
154      </row>
155
156      <row>
157       <entry><link linkend="catalog-pg-inherits"><structname>pg_inherits</structname></link></entry>
158       <entry>table inheritance hierarchy</entry>
159      </row>
160
161      <row>
162       <entry><link linkend="catalog-pg-language"><structname>pg_language</structname></link></entry>
163       <entry>languages for writing functions</entry>
164      </row>
165
166      <row>
167       <entry><link linkend="catalog-pg-largeobject"><structname>pg_largeobject</structname></link></entry>
168       <entry>data pages for large objects</entry>
169      </row>
170
171      <row>
172       <entry><link linkend="catalog-pg-largeobject-metadata"><structname>pg_largeobject_metadata</structname></link></entry>
173       <entry>metadata for large objects</entry>
174      </row>
175
176      <row>
177       <entry><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link></entry>
178       <entry>schemas</entry>
179      </row>
180
181      <row>
182       <entry><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link></entry>
183       <entry>access method operator classes</entry>
184      </row>
185
186      <row>
187       <entry><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link></entry>
188       <entry>operators</entry>
189      </row>
190
191      <row>
192       <entry><link linkend="catalog-pg-opfamily"><structname>pg_opfamily</structname></link></entry>
193       <entry>access method operator families</entry>
194      </row>
195
196      <row>
197       <entry><link linkend="catalog-pg-pltemplate"><structname>pg_pltemplate</structname></link></entry>
198       <entry>template data for procedural languages</entry>
199      </row>
200
201      <row>
202       <entry><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link></entry>
203       <entry>functions and procedures</entry>
204      </row>
205
206      <row>
207       <entry><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link></entry>
208       <entry>query rewrite rules</entry>
209      </row>
210
211      <row>
212       <entry><link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link></entry>
213       <entry>dependencies on shared objects</entry>
214      </row>
215
216      <row>
217       <entry><link linkend="catalog-pg-shdescription"><structname>pg_shdescription</structname></link></entry>
218       <entry>comments on shared objects</entry>
219      </row>
220
221      <row>
222       <entry><link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link></entry>
223       <entry>planner statistics</entry>
224      </row>
225
226      <row>
227       <entry><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link></entry>
228       <entry>tablespaces within this database cluster</entry>
229      </row>
230
231      <row>
232       <entry><link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link></entry>
233       <entry>triggers</entry>
234      </row>
235
236      <row>
237       <entry><link linkend="catalog-pg-ts-config"><structname>pg_ts_config</structname></link></entry>
238       <entry>text search configurations</entry>
239      </row>
240
241      <row>
242       <entry><link linkend="catalog-pg-ts-config-map"><structname>pg_ts_config_map</structname></link></entry>
243       <entry>text search configurations' token mappings</entry>
244      </row>
245
246      <row>
247       <entry><link linkend="catalog-pg-ts-dict"><structname>pg_ts_dict</structname></link></entry>
248       <entry>text search dictionaries</entry>
249      </row>
250
251      <row>
252       <entry><link linkend="catalog-pg-ts-parser"><structname>pg_ts_parser</structname></link></entry>
253       <entry>text search parsers</entry>
254      </row>
255
256      <row>
257       <entry><link linkend="catalog-pg-ts-template"><structname>pg_ts_template</structname></link></entry>
258       <entry>text search templates</entry>
259      </row>
260
261      <row>
262       <entry><link linkend="catalog-pg-type"><structname>pg_type</structname></link></entry>
263       <entry>data types</entry>
264      </row>
265
266      <row>
267       <entry><link linkend="catalog-pg-user-mapping"><structname>pg_user_mapping</structname></link></entry>
268       <entry>mappings of users to foreign servers</entry>
269      </row>
270     </tbody>
271    </tgroup>
272   </table>
273  </sect1>
274
275
276  <sect1 id="catalog-pg-aggregate">
277   <title><structname>pg_aggregate</structname></title>
278
279   <indexterm zone="catalog-pg-aggregate">
280    <primary>pg_aggregate</primary>
281   </indexterm>
282
283   <para>
284    The catalog <structname>pg_aggregate</structname> stores information about
285    aggregate functions.  An aggregate function is a function that
286    operates on a set of values (typically one column from each row
287    that matches a query condition) and returns a single value computed
288    from all these values.  Typical aggregate functions are
289    <function>sum</function>, <function>count</function>, and
290    <function>max</function>.  Each entry in
291    <structname>pg_aggregate</structname> is an extension of an entry
292    in <structname>pg_proc</structname>.  The <structname>pg_proc</structname>
293    entry carries the aggregate's name, input and output data types, and
294    other information that is similar to ordinary functions.
295   </para>
296
297   <table>
298    <title><structname>pg_aggregate</> Columns</title>
299
300    <tgroup cols="4">
301     <thead>
302      <row>
303       <entry>Name</entry>
304       <entry>Type</entry>
305       <entry>References</entry>
306       <entry>Description</entry>
307      </row>
308     </thead>
309     <tbody>
310      <row>
311       <entry><structfield>aggfnoid</structfield></entry>
312       <entry><type>regproc</type></entry>
313       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
314       <entry><structname>pg_proc</structname> OID of the aggregate function</entry>
315      </row>
316      <row>
317       <entry><structfield>aggtransfn</structfield></entry>
318       <entry><type>regproc</type></entry>
319       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
320       <entry>Transition function</entry>
321      </row>
322      <row>
323       <entry><structfield>aggfinalfn</structfield></entry>
324       <entry><type>regproc</type></entry>
325       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
326       <entry>Final function (zero if none)</entry>
327      </row>
328      <row>
329       <entry><structfield>aggsortop</structfield></entry>
330       <entry><type>oid</type></entry>
331       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
332       <entry>Associated sort operator (zero if none)</entry>
333      </row>
334      <row>
335       <entry><structfield>aggtranstype</structfield></entry>
336       <entry><type>oid</type></entry>
337       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
338       <entry>Data type of the aggregate function's internal transition (state) data</entry>
339      </row>
340      <row>
341       <entry><structfield>agginitval</structfield></entry>
342       <entry><type>text</type></entry>
343       <entry></entry>
344       <entry>
345        The initial value of the transition state.  This is a text
346        field containing the initial value in its external string
347        representation.  If this field is null, the transition state
348        value starts out null.
349       </entry>
350      </row>
351     </tbody>
352    </tgroup>
353   </table>
354
355   <para>
356    New aggregate functions are registered with the <xref
357    linkend="sql-createaggregate">
358    command.  See <xref linkend="xaggr"> for more information about
359    writing aggregate functions and the meaning of the transition
360    functions, etc.
361   </para>
362
363  </sect1>
364
365
366  <sect1 id="catalog-pg-am">
367   <title><structname>pg_am</structname></title>
368
369   <indexterm zone="catalog-pg-am">
370    <primary>pg_am</primary>
371   </indexterm>
372
373   <para>
374    The catalog <structname>pg_am</structname> stores information about index
375    access methods.  There is one row for each index access method supported by
376    the system.  The contents of this catalog are discussed in detail in
377    <xref linkend="indexam">.
378   </para>
379
380   <table>
381    <title><structname>pg_am</> Columns</title>
382
383    <tgroup cols="4">
384     <thead>
385      <row>
386       <entry>Name</entry>
387       <entry>Type</entry>
388       <entry>References</entry>
389       <entry>Description</entry>
390      </row>
391     </thead>
392     <tbody>
393
394      <row>
395       <entry><structfield>amname</structfield></entry>
396       <entry><type>name</type></entry>
397       <entry></entry>
398       <entry>Name of the access method</entry>
399      </row>
400
401      <row>
402       <entry><structfield>amstrategies</structfield></entry>
403       <entry><type>int2</type></entry>
404       <entry></entry>
405       <entry>Number of operator strategies for this access method,
406        or zero if access method does not have a fixed set of operator
407        strategies</entry>
408      </row>
409
410      <row>
411       <entry><structfield>amsupport</structfield></entry>
412       <entry><type>int2</type></entry>
413       <entry></entry>
414       <entry>Number of support routines for this access method</entry>
415      </row>
416
417      <row>
418       <entry><structfield>amcanorder</structfield></entry>
419       <entry><type>bool</type></entry>
420       <entry></entry>
421       <entry>Does the access method support ordered scans?</entry>
422      </row>
423
424      <row>
425       <entry><structfield>amcanbackward</structfield></entry>
426       <entry><type>bool</type></entry>
427       <entry></entry>
428       <entry>Does the access method support backward scanning?</entry>
429      </row>
430
431      <row>
432       <entry><structfield>amcanunique</structfield></entry>
433       <entry><type>bool</type></entry>
434       <entry></entry>
435       <entry>Does the access method support unique indexes?</entry>
436      </row>
437
438      <row>
439       <entry><structfield>amcanmulticol</structfield></entry>
440       <entry><type>bool</type></entry>
441       <entry></entry>
442       <entry>Does the access method support multicolumn indexes?</entry>
443      </row>
444
445      <row>
446       <entry><structfield>amoptionalkey</structfield></entry>
447       <entry><type>bool</type></entry>
448       <entry></entry>
449       <entry>Does the access method support a scan without any constraint
450        for the first index column?</entry>
451      </row>
452
453      <row>
454       <entry><structfield>amindexnulls</structfield></entry>
455       <entry><type>bool</type></entry>
456       <entry></entry>
457       <entry>Does the access method support null index entries?</entry>
458      </row>
459
460      <row>
461       <entry><structfield>amsearchnulls</structfield></entry>
462       <entry><type>bool</type></entry>
463       <entry></entry>
464       <entry>Does the access method support <literal>IS NULL</>/<literal>NOT NULL</> searches?</entry>
465      </row>
466
467      <row>
468       <entry><structfield>amstorage</structfield></entry>
469       <entry><type>bool</type></entry>
470       <entry></entry>
471       <entry>Can index storage data type differ from column data type?</entry>
472      </row>
473
474      <row>
475       <entry><structfield>amclusterable</structfield></entry>
476       <entry><type>bool</type></entry>
477       <entry></entry>
478       <entry>Can an index of this type be clustered on?</entry>
479      </row>
480
481      <row>
482       <entry><structfield>amkeytype</structfield></entry>
483       <entry><type>oid</type></entry>
484       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
485       <entry>Type of data stored in index, or zero if not a fixed type</entry>
486      </row>
487
488      <row>
489       <entry><structfield>aminsert</structfield></entry>
490       <entry><type>regproc</type></entry>
491       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
492       <entry><quote>Insert this tuple</quote> function</entry>
493      </row>
494
495      <row>
496       <entry><structfield>ambeginscan</structfield></entry>
497       <entry><type>regproc</type></entry>
498       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
499       <entry><quote>Start new scan</quote> function</entry>
500      </row>
501
502      <row>
503       <entry><structfield>amgettuple</structfield></entry>
504       <entry><type>regproc</type></entry>
505       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
506       <entry><quote>Next valid tuple</quote> function, or zero if none</entry>
507      </row>
508
509      <row>
510       <entry><structfield>amgetbitmap</structfield></entry>
511       <entry><type>regproc</type></entry>
512       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
513       <entry><quote>Fetch all valid tuples</quote> function, or zero if none</entry>
514      </row>
515
516      <row>
517       <entry><structfield>amrescan</structfield></entry>
518       <entry><type>regproc</type></entry>
519       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
520       <entry><quote>Restart this scan</quote> function</entry>
521      </row>
522
523      <row>
524       <entry><structfield>amendscan</structfield></entry>
525       <entry><type>regproc</type></entry>
526       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
527       <entry><quote>End this scan</quote> function</entry>
528      </row>
529
530      <row>
531       <entry><structfield>ammarkpos</structfield></entry>
532       <entry><type>regproc</type></entry>
533       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
534       <entry><quote>Mark current scan position</quote> function</entry>
535      </row>
536
537      <row>
538       <entry><structfield>amrestrpos</structfield></entry>
539       <entry><type>regproc</type></entry>
540       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
541       <entry><quote>Restore marked scan position</quote> function</entry>
542      </row>
543
544      <row>
545       <entry><structfield>ambuild</structfield></entry>
546       <entry><type>regproc</type></entry>
547       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
548       <entry><quote>Build new index</quote> function</entry>
549      </row>
550
551      <row>
552       <entry><structfield>ambulkdelete</structfield></entry>
553       <entry><type>regproc</type></entry>
554       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
555       <entry>Bulk-delete function</entry>
556      </row>
557
558      <row>
559       <entry><structfield>amvacuumcleanup</structfield></entry>
560       <entry><type>regproc</type></entry>
561       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
562       <entry>Post-<command>VACUUM</command> cleanup function</entry>
563      </row>
564
565      <row>
566       <entry><structfield>amcostestimate</structfield></entry>
567       <entry><type>regproc</type></entry>
568       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
569       <entry>Function to estimate cost of an index scan</entry>
570      </row>
571
572      <row>
573       <entry><structfield>amoptions</structfield></entry>
574       <entry><type>regproc</type></entry>
575       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
576       <entry>Function to parse and validate <structfield>reloptions</> for an index</entry>
577      </row>
578
579     </tbody>
580    </tgroup>
581   </table>
582
583  </sect1>
584
585
586  <sect1 id="catalog-pg-amop">
587   <title><structname>pg_amop</structname></title>
588
589   <indexterm zone="catalog-pg-amop">
590    <primary>pg_amop</primary>
591   </indexterm>
592
593   <para>
594    The catalog <structname>pg_amop</structname> stores information about
595    operators associated with access method operator families.  There is one
596    row for each operator that is a member of an operator family.  An operator
597    can appear in more than one family, but cannot appear in more than one
598    position within a family.
599   </para>
600
601   <table>
602    <title><structname>pg_amop</> Columns</title>
603
604    <tgroup cols="4">
605     <thead>
606      <row>
607       <entry>Name</entry>
608       <entry>Type</entry>
609       <entry>References</entry>
610       <entry>Description</entry>
611      </row>
612     </thead>
613     <tbody>
614
615      <row>
616       <entry><structfield>amopfamily</structfield></entry>
617       <entry><type>oid</type></entry>
618       <entry><literal><link linkend="catalog-pg-opfamily"><structname>pg_opfamily</structname></link>.oid</literal></entry>
619       <entry>The operator family this entry is for</entry>
620      </row>
621
622      <row>
623       <entry><structfield>amoplefttype</structfield></entry>
624       <entry><type>oid</type></entry>
625       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
626       <entry>Left-hand input data type of operator</entry>
627      </row>
628
629      <row>
630       <entry><structfield>amoprighttype</structfield></entry>
631       <entry><type>oid</type></entry>
632       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
633       <entry>Right-hand input data type of operator</entry>
634      </row>
635
636      <row>
637       <entry><structfield>amopstrategy</structfield></entry>
638       <entry><type>int2</type></entry>
639       <entry></entry>
640       <entry>Operator strategy number</entry>
641      </row>
642
643      <row>
644       <entry><structfield>amopopr</structfield></entry>
645       <entry><type>oid</type></entry>
646       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
647       <entry>OID of the operator</entry>
648      </row>
649
650      <row>
651       <entry><structfield>amopmethod</structfield></entry>
652       <entry><type>oid</type></entry>
653       <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
654       <entry>Index access method operator family is for</entry>
655      </row>
656
657     </tbody>
658    </tgroup>
659   </table>
660
661   <para>
662    An entry's <structfield>amopmethod</> must match the
663    <structname>opfmethod</> of its containing operator family (including
664    <structfield>amopmethod</> here is an intentional denormalization of the
665    catalog structure for performance reasons).  Also,
666    <structfield>amoplefttype</> and <structfield>amoprighttype</> must match
667    the <structfield>oprleft</> and <structfield>oprright</> fields of the
668    referenced <structname>pg_operator</> entry.
669   </para>
670
671  </sect1>
672
673
674  <sect1 id="catalog-pg-amproc">
675   <title><structname>pg_amproc</structname></title>
676
677   <indexterm zone="catalog-pg-amproc">
678    <primary>pg_amproc</primary>
679   </indexterm>
680
681   <para>
682    The catalog <structname>pg_amproc</structname> stores information about
683    support procedures associated with access method operator families.  There
684    is one row for each support procedure belonging to an operator family.
685   </para>
686
687   <table>
688    <title><structname>pg_amproc</structname> Columns</title>
689
690    <tgroup cols="4">
691     <thead>
692      <row>
693       <entry>Name</entry>
694       <entry>Type</entry>
695       <entry>References</entry>
696       <entry>Description</entry>
697      </row>
698     </thead>
699     <tbody>
700
701      <row>
702       <entry><structfield>amprocfamily</structfield></entry>
703       <entry><type>oid</type></entry>
704       <entry><literal><link linkend="catalog-pg-opfamily"><structname>pg_opfamily</structname></link>.oid</literal></entry>
705       <entry>The operator family this entry is for</entry>
706      </row>
707
708      <row>
709       <entry><structfield>amproclefttype</structfield></entry>
710       <entry><type>oid</type></entry>
711       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
712       <entry>Left-hand input data type of associated operator</entry>
713      </row>
714
715      <row>
716       <entry><structfield>amprocrighttype</structfield></entry>
717       <entry><type>oid</type></entry>
718       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
719       <entry>Right-hand input data type of associated operator</entry>
720      </row>
721
722      <row>
723       <entry><structfield>amprocnum</structfield></entry>
724       <entry><type>int2</type></entry>
725       <entry></entry>
726       <entry>Support procedure number</entry>
727      </row>
728
729      <row>
730       <entry><structfield>amproc</structfield></entry>
731       <entry><type>regproc</type></entry>
732       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
733       <entry>OID of the procedure</entry>
734      </row>
735
736     </tbody>
737    </tgroup>
738   </table>
739
740   <para>
741    The usual interpretation of the
742    <structfield>amproclefttype</> and <structfield>amprocrighttype</> fields
743    is that they identify the left and right input types of the operator(s)
744    that a particular support procedure supports.  For some access methods
745    these match the input data type(s) of the support procedure itself, for
746    others not.  There is a notion of <quote>default</> support procedures for
747    an index, which are those with <structfield>amproclefttype</> and
748    <structfield>amprocrighttype</> both equal to the index opclass's
749    <structfield>opcintype</>.
750   </para>
751
752  </sect1>
753
754
755  <sect1 id="catalog-pg-attrdef">
756   <title><structname>pg_attrdef</structname></title>
757
758   <indexterm zone="catalog-pg-attrdef">
759    <primary>pg_attrdef</primary>
760   </indexterm>
761
762   <para>
763    The catalog <structname>pg_attrdef</structname> stores column default values.  The main information
764    about columns is stored in <structname>pg_attribute</structname>
765    (see below).  Only columns that explicitly specify a default value
766    (when the table is created or the column is added) will have an
767    entry here.
768   </para>
769
770   <table>
771    <title><structname>pg_attrdef</> Columns</title>
772
773    <tgroup cols="4">
774     <thead>
775      <row>
776       <entry>Name</entry>
777       <entry>Type</entry>
778       <entry>References</entry>
779       <entry>Description</entry>
780      </row>
781     </thead>
782
783     <tbody>
784      <row>
785       <entry><structfield>adrelid</structfield></entry>
786       <entry><type>oid</type></entry>
787       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
788       <entry>The table this column belongs to</entry>
789      </row>
790
791      <row>
792       <entry><structfield>adnum</structfield></entry>
793       <entry><type>int2</type></entry>
794       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
795       <entry>The number of the column</entry>
796      </row>
797
798      <row>
799       <entry><structfield>adbin</structfield></entry>
800       <entry><type>text</type></entry>
801       <entry></entry>
802       <entry>The internal representation of the column default value</entry>
803      </row>
804
805      <row>
806       <entry><structfield>adsrc</structfield></entry>
807       <entry><type>text</type></entry>
808       <entry></entry>
809       <entry>A human-readable representation of the default value</entry>
810      </row>
811     </tbody>
812    </tgroup>
813   </table>
814
815    <para>
816     The <structfield>adsrc</structfield> field is historical, and is best
817     not used, because it does not track outside changes that might affect
818     the representation of the default value.  Reverse-compiling the
819     <structfield>adbin</structfield> field (with <function>pg_get_expr</> for
820     example) is a better way to display the default value.
821    </para>
822
823  </sect1>
824
825
826  <sect1 id="catalog-pg-attribute">
827   <title><structname>pg_attribute</structname></title>
828
829   <indexterm zone="catalog-pg-attribute">
830    <primary>pg_attribute</primary>
831   </indexterm>
832
833   <para>
834    The catalog <structname>pg_attribute</structname> stores information about
835    table columns.  There will be exactly one
836    <structname>pg_attribute</structname> row for every column in every
837    table in the database.  (There will also be attribute entries for
838    indexes, and indeed all objects that have <structname>pg_class</structname>
839    entries.)
840   </para>
841
842   <para>
843    The term attribute is equivalent to column and is used for
844    historical reasons.
845   </para>
846
847   <table>
848    <title><structname>pg_attribute</> Columns</title>
849
850    <tgroup cols="4">
851     <thead>
852      <row>
853       <entry>Name</entry>
854       <entry>Type</entry>
855       <entry>References</entry>
856       <entry>Description</entry>
857      </row>
858     </thead>
859
860     <tbody>
861      <row>
862       <entry><structfield>attrelid</structfield></entry>
863       <entry><type>oid</type></entry>
864       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
865       <entry>The table this column belongs to</entry>
866      </row>
867
868      <row>
869       <entry><structfield>attname</structfield></entry>
870       <entry><type>name</type></entry>
871       <entry></entry>
872       <entry>The column name</entry>
873      </row>
874
875      <row>
876       <entry><structfield>atttypid</structfield></entry>
877       <entry><type>oid</type></entry>
878       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
879       <entry>The data type of this column</entry>
880      </row>
881
882      <row>
883       <entry><structfield>attstattarget</structfield></entry>
884       <entry><type>int4</type></entry>
885       <entry></entry>
886       <entry>
887        <structfield>attstattarget</structfield> controls the level of detail
888        of statistics accumulated for this column by
889        <xref linkend="sql-analyze">.
890        A zero value indicates that no statistics should be collected.
891        A negative value says to use the system default statistics target.
892        The exact meaning of positive values is data type-dependent.
893        For scalar data types, <structfield>attstattarget</structfield>
894        is both the target number of <quote>most common values</quote>
895        to collect, and the target number of histogram bins to create.
896       </entry>
897      </row>
898
899      <row>
900       <entry><structfield>attlen</structfield></entry>
901       <entry><type>int2</type></entry>
902       <entry></entry>
903       <entry>
904        A copy of <literal>pg_type.typlen</literal> of this column's
905        type
906       </entry>
907      </row>
908
909      <row>
910       <entry><structfield>attnum</structfield></entry>
911       <entry><type>int2</type></entry>
912       <entry></entry>
913       <entry>
914        The number of the column.  Ordinary columns are numbered from 1
915        up.  System columns, such as <structfield>oid</structfield>,
916        have (arbitrary) negative numbers.
917       </entry>
918      </row>
919
920      <row>
921       <entry><structfield>attndims</structfield></entry>
922       <entry><type>int4</type></entry>
923       <entry></entry>
924       <entry>
925        Number of dimensions, if the column is an array type; otherwise 0.
926        (Presently, the number of dimensions of an array is not enforced,
927        so any nonzero value effectively means <quote>it's an array</>.)
928       </entry>
929      </row>
930
931      <row>
932       <entry><structfield>attcacheoff</structfield></entry>
933       <entry><type>int4</type></entry>
934       <entry></entry>
935       <entry>
936        Always -1 in storage, but when loaded into a row descriptor
937        in memory this might be updated to cache the offset of the attribute
938        within the row
939       </entry>
940      </row>
941
942      <row>
943       <entry><structfield>atttypmod</structfield></entry>
944       <entry><type>int4</type></entry>
945       <entry></entry>
946       <entry>
947        <structfield>atttypmod</structfield> records type-specific data
948        supplied at table creation time (for example, the maximum
949        length of a <type>varchar</type> column).  It is passed to
950        type-specific input functions and length coercion functions.
951        The value will generally be -1 for types that do not need <structfield>atttypmod</>.
952       </entry>
953      </row>
954
955      <row>
956       <entry><structfield>attbyval</structfield></entry>
957       <entry><type>bool</type></entry>
958       <entry></entry>
959       <entry>
960        A copy of <literal>pg_type.typbyval</> of this column's type
961       </entry>
962      </row>
963
964      <row>
965       <entry><structfield>attstorage</structfield></entry>
966       <entry><type>char</type></entry>
967       <entry></entry>
968       <entry>
969        Normally a copy of <literal>pg_type.typstorage</> of this
970        column's type.  For TOAST-able data types, this can be altered
971        after column creation to control storage policy.
972       </entry>
973      </row>
974
975      <row>
976       <entry><structfield>attalign</structfield></entry>
977       <entry><type>char</type></entry>
978       <entry></entry>
979       <entry>
980        A copy of <literal>pg_type.typalign</> of this column's type
981       </entry>
982      </row>
983
984      <row>
985       <entry><structfield>attnotnull</structfield></entry>
986       <entry><type>bool</type></entry>
987       <entry></entry>
988       <entry>
989        This represents a not-null constraint.  It is possible to
990        change this column to enable or disable the constraint.
991       </entry>
992      </row>
993
994      <row>
995       <entry><structfield>atthasdef</structfield></entry>
996       <entry><type>bool</type></entry>
997       <entry></entry>
998       <entry>
999        This column has a default value, in which case there will be a
1000        corresponding entry in the <structname>pg_attrdef</structname>
1001        catalog that actually defines the value.
1002       </entry>
1003      </row>
1004
1005      <row>
1006       <entry><structfield>attisdropped</structfield></entry>
1007       <entry><type>bool</type></entry>
1008       <entry></entry>
1009       <entry>
1010        This column has been dropped and is no longer valid.  A dropped
1011        column is still physically present in the table, but is
1012        ignored by the parser and so cannot be accessed via SQL.
1013       </entry>
1014      </row>
1015
1016      <row>
1017       <entry><structfield>attislocal</structfield></entry>
1018       <entry><type>bool</type></entry>
1019       <entry></entry>
1020       <entry>
1021        This column is defined locally in the relation.  Note that a column can
1022        be locally defined and inherited simultaneously.
1023       </entry>
1024      </row>
1025
1026      <row>
1027       <entry><structfield>attinhcount</structfield></entry>
1028       <entry><type>int4</type></entry>
1029       <entry></entry>
1030       <entry>
1031        The number of direct ancestors this column has.  A column with a
1032        nonzero number of ancestors cannot be dropped nor renamed.
1033       </entry>
1034      </row>
1035
1036      <row>
1037       <entry><structfield>attacl</structfield></entry>
1038       <entry><type>aclitem[]</type></entry>
1039       <entry></entry>
1040       <entry>
1041        Column-level access privileges, if any have been granted specifically
1042        on this column
1043       </entry>
1044      </row>
1045
1046      <row>
1047       <entry><structfield>attoptions</structfield></entry>
1048       <entry><type>text[]</type></entry>
1049       <entry></entry>
1050       <entry>
1051        Attribute-level options, as <quote>keyword=value</> strings
1052       </entry>
1053      </row>
1054
1055     </tbody>
1056    </tgroup>
1057   </table>
1058
1059   <para>
1060    In a dropped column's <structname>pg_attribute</structname> entry,
1061    <structfield>atttypid</structfield> is reset to zero, but
1062    <structfield>attlen</structfield> and the other fields copied from
1063    <structname>pg_type</> are still valid.  This arrangement is needed
1064    to cope with the situation where the dropped column's data type was
1065    later dropped, and so there is no <structname>pg_type</> row anymore.
1066    <structfield>attlen</structfield> and the other fields can be used
1067    to interpret the contents of a row of the table.
1068   </para>
1069  </sect1>
1070
1071
1072  <sect1 id="catalog-pg-authid">
1073   <title><structname>pg_authid</structname></title>
1074
1075   <indexterm zone="catalog-pg-authid">
1076    <primary>pg_authid</primary>
1077   </indexterm>
1078
1079   <para>
1080    The catalog <structname>pg_authid</structname> contains information about
1081    database authorization identifiers (roles).  A role subsumes the concepts
1082    of <quote>users</> and <quote>groups</>.  A user is essentially just a
1083    role with the <structfield>rolcanlogin</> flag set.  Any role (with or
1084    without <structfield>rolcanlogin</>) can have other roles as members; see
1085    <link linkend="catalog-pg-auth-members"><structname>pg_auth_members</structname></link>.
1086   </para>
1087
1088   <para>
1089    Since this catalog contains passwords, it must not be publicly readable.
1090    <link linkend="view-pg-roles"><structname>pg_roles</structname></link>
1091    is a publicly readable view on
1092    <structname>pg_authid</structname> that blanks out the password field.
1093   </para>
1094
1095   <para>
1096    <xref linkend="user-manag"> contains detailed information about user and
1097    privilege management.
1098   </para>
1099
1100   <para>
1101    Because user identities are cluster-wide,
1102    <structname>pg_authid</structname>
1103    is shared across all databases of a cluster: there is only one
1104    copy of <structname>pg_authid</structname> per cluster, not
1105    one per database.
1106   </para>
1107
1108   <table>
1109    <title><structname>pg_authid</> Columns</title>
1110
1111    <tgroup cols="3">
1112     <thead>
1113      <row>
1114       <entry>Name</entry>
1115       <entry>Type</entry>
1116       <entry>Description</entry>
1117      </row>
1118     </thead>
1119
1120     <tbody>
1121      <row>
1122       <entry><structfield>rolname</structfield></entry>
1123       <entry><type>name</type></entry>
1124       <entry>Role name</entry>
1125      </row>
1126
1127      <row>
1128       <entry><structfield>rolsuper</structfield></entry>
1129       <entry><type>bool</type></entry>
1130       <entry>Role has superuser privileges</entry>
1131      </row>
1132
1133      <row>
1134       <entry><structfield>rolinherit</structfield></entry>
1135       <entry><type>bool</type></entry>
1136       <entry>Role automatically inherits privileges of roles it is a
1137        member of</entry>
1138      </row>
1139
1140      <row>
1141       <entry><structfield>rolcreaterole</structfield></entry>
1142       <entry><type>bool</type></entry>
1143       <entry>Role can create more roles</entry>
1144      </row>
1145
1146      <row>
1147       <entry><structfield>rolcreatedb</structfield></entry>
1148       <entry><type>bool</type></entry>
1149       <entry>Role can create databases</entry>
1150      </row>
1151
1152      <row>
1153       <entry><structfield>rolcatupdate</structfield></entry>
1154       <entry><type>bool</type></entry>
1155       <entry>
1156        Role can update system catalogs directly.  (Even a superuser cannot do
1157        this unless this column is true)
1158       </entry>
1159      </row>
1160
1161      <row>
1162       <entry><structfield>rolcanlogin</structfield></entry>
1163       <entry><type>bool</type></entry>
1164       <entry>
1165        Role can log in. That is, this role can be given as the initial
1166        session authorization identifier.
1167       </entry>
1168      </row>
1169
1170      <row>
1171       <entry><structfield>rolconnlimit</structfield></entry>
1172       <entry><type>int4</type></entry>
1173       <entry>
1174        For roles that can log in, this sets maximum number of concurrent
1175        connections this role can make.  -1 means no limit.
1176       </entry>
1177      </row>
1178
1179      <row>
1180       <entry><structfield>rolpassword</structfield></entry>
1181       <entry><type>text</type></entry>
1182       <entry>
1183        Password (possibly encrypted); null if none.  If the password is
1184        encrypted, this column will contain the string md5 followed by a
1185        32-character hexadecimal MD5 hash.  The MD5 hash will be of the
1186        user's password concatenated to their username (for example, if
1187        user joe has password xyzzy, <productname>PostgreSQL</> will store
1188        the md5 hash of xyzzyjoe).
1189       </entry>
1190      </row>
1191
1192      <row>
1193       <entry><structfield>rolvaliduntil</structfield></entry>
1194       <entry><type>timestamptz</type></entry>
1195       <entry>Password expiry time (only used for password authentication);
1196        null if no expiration</entry>
1197      </row>
1198     </tbody>
1199    </tgroup>
1200   </table>
1201
1202  </sect1>
1203
1204
1205  <sect1 id="catalog-pg-auth-members">
1206   <title><structname>pg_auth_members</structname></title>
1207
1208   <indexterm zone="catalog-pg-auth-members">
1209    <primary>pg_auth_members</primary>
1210   </indexterm>
1211
1212   <para>
1213    The catalog <structname>pg_auth_members</structname> shows the membership
1214    relations between roles.  Any non-circular set of relationships is allowed.
1215   </para>
1216
1217   <para>
1218    Because user identities are cluster-wide,
1219    <structname>pg_auth_members</structname>
1220    is shared across all databases of a cluster: there is only one
1221    copy of <structname>pg_auth_members</structname> per cluster, not
1222    one per database.
1223   </para>
1224
1225   <table>
1226    <title><structname>pg_auth_members</> Columns</title>
1227
1228    <tgroup cols="4">
1229     <thead>
1230      <row>
1231       <entry>Name</entry>
1232       <entry>Type</entry>
1233       <entry>References</entry>
1234       <entry>Description</entry>
1235      </row>
1236     </thead>
1237
1238     <tbody>
1239      <row>
1240       <entry><structfield>roleid</structfield></entry>
1241       <entry><type>oid</type></entry>
1242       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1243       <entry>ID of a role that has a member</entry>
1244      </row>
1245
1246      <row>
1247       <entry><structfield>member</structfield></entry>
1248       <entry><type>oid</type></entry>
1249       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1250       <entry>ID of a role that is a member of <structfield>roleid</></entry>
1251      </row>
1252
1253      <row>
1254       <entry><structfield>grantor</structfield></entry>
1255       <entry><type>oid</type></entry>
1256       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1257       <entry>ID of the role that granted this membership</entry>
1258      </row>
1259
1260      <row>
1261       <entry><structfield>admin_option</structfield></entry>
1262       <entry><type>bool</type></entry>
1263       <entry></entry>
1264       <entry>True if <structfield>member</> can grant membership in
1265        <structfield>roleid</> to others</entry>
1266      </row>
1267     </tbody>
1268    </tgroup>
1269   </table>
1270
1271  </sect1>
1272
1273
1274  <sect1 id="catalog-pg-cast">
1275   <title><structname>pg_cast</structname></title>
1276
1277   <indexterm zone="catalog-pg-cast">
1278    <primary>pg_cast</primary>
1279   </indexterm>
1280
1281   <para>
1282    The catalog <structname>pg_cast</structname> stores data type conversion
1283    paths, both built-in paths and those defined with
1284    <xref linkend="sql-createcast">.
1285   </para>
1286
1287   <para>
1288    It should be noted that <structname>pg_cast</structname> does not represent
1289    every type conversion that the system knows how to perform; only those that
1290    cannot be deduced from some generic rule.  For example, casting between a
1291    domain and its base type is not explicitly represented in
1292    <structname>pg_cast</structname>.  Another important exception is that
1293    <quote>automatic I/O conversion casts</>, those performed using a data
1294    type's own I/O functions to convert to or from <type>text</> or other
1295    string types, are not explicitly represented in
1296    <structname>pg_cast</structname>.
1297   </para>
1298
1299   <table>
1300    <title><structname>pg_cast</> Columns</title>
1301
1302    <tgroup cols="4">
1303     <thead>
1304      <row>
1305       <entry>Name</entry>
1306       <entry>Type</entry>
1307       <entry>References</entry>
1308       <entry>Description</entry>
1309      </row>
1310     </thead>
1311
1312     <tbody>
1313      <row>
1314       <entry><structfield>castsource</structfield></entry>
1315       <entry><type>oid</type></entry>
1316       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1317       <entry>OID of the source data type</entry>
1318      </row>
1319
1320      <row>
1321       <entry><structfield>casttarget</structfield></entry>
1322       <entry><type>oid</type></entry>
1323       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1324       <entry>OID of the target data type</entry>
1325      </row>
1326
1327      <row>
1328       <entry><structfield>castfunc</structfield></entry>
1329       <entry><type>oid</type></entry>
1330       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
1331       <entry>
1332        The OID of the function to use to perform this cast.  Zero is
1333        stored if the cast method doesn't require a function.
1334       </entry>
1335      </row>
1336
1337      <row>
1338       <entry><structfield>castcontext</structfield></entry>
1339       <entry><type>char</type></entry>
1340       <entry></entry>
1341       <entry>
1342        Indicates what contexts the cast can be invoked in.
1343        <literal>e</> means only as an explicit cast (using
1344        <literal>CAST</> or <literal>::</> syntax).
1345        <literal>a</> means implicitly in assignment
1346        to a target column, as well as explicitly.
1347        <literal>i</> means implicitly in expressions, as well as the
1348        other cases.
1349       </entry>
1350      </row>
1351      <row>
1352       <entry><structfield>castmethod</structfield></entry>
1353       <entry><type>char</type></entry>
1354       <entry></entry>
1355       <entry>
1356        Indicates how the cast is performed.
1357        <literal>f</> means that the function specified in the <structfield>castfunc</> field is used.
1358        <literal>i</> means that the input/output functions are used.
1359        <literal>b</> means that the types are binary-coercible, thus no conversion is required.
1360       </entry>
1361      </row>
1362     </tbody>
1363    </tgroup>
1364   </table>
1365
1366   <para>
1367    The cast functions listed in <structname>pg_cast</structname> must
1368    always take the cast source type as their first argument type, and
1369    return the cast destination type as their result type.  A cast
1370    function can have up to three arguments.  The second argument,
1371    if present, must be type <type>integer</>; it receives the type
1372    modifier associated with the destination type, or <literal>-1</>
1373    if there is none.  The third argument,
1374    if present, must be type <type>boolean</>; it receives <literal>true</>
1375    if the cast is an explicit cast, <literal>false</> otherwise.
1376   </para>
1377
1378   <para>
1379    It is legitimate to create a <structname>pg_cast</structname> entry
1380    in which the source and target types are the same, if the associated
1381    function takes more than one argument.  Such entries represent
1382    <quote>length coercion functions</> that coerce values of the type
1383    to be legal for a particular type modifier value.
1384   </para>
1385
1386   <para>
1387    When a <structname>pg_cast</structname> entry has different source and
1388    target types and a function that takes more than one argument, it
1389    represents converting from one type to another and applying a length
1390    coercion in a single step.  When no such entry is available, coercion
1391    to a type that uses a type modifier involves two steps, one to
1392    convert between data types and a second to apply the modifier.
1393   </para>
1394  </sect1>
1395
1396  <sect1 id="catalog-pg-class">
1397   <title><structname>pg_class</structname></title>
1398
1399   <indexterm zone="catalog-pg-class">
1400    <primary>pg_class</primary>
1401   </indexterm>
1402
1403   <para>
1404    The catalog <structname>pg_class</structname> catalogs tables and most
1405    everything else that has columns or is otherwise similar to a
1406    table.  This includes indexes (but see also
1407    <structname>pg_index</structname>), sequences, views, composite types,
1408    and TOAST tables; see <structfield>relkind</>.
1409    Below, when we mean all of these
1410    kinds of objects we speak of <quote>relations</quote>.  Not all
1411    columns are meaningful for all relation types.
1412   </para>
1413
1414   <table>
1415    <title><structname>pg_class</> Columns</title>
1416
1417    <tgroup cols="4">
1418     <thead>
1419      <row>
1420       <entry>Name</entry>
1421       <entry>Type</entry>
1422       <entry>References</entry>
1423       <entry>Description</entry>
1424      </row>
1425     </thead>
1426
1427     <tbody>
1428      <row>
1429       <entry><structfield>relname</structfield></entry>
1430       <entry><type>name</type></entry>
1431       <entry></entry>
1432       <entry>Name of the table, index, view, etc.</entry>
1433      </row>
1434
1435      <row>
1436       <entry><structfield>relnamespace</structfield></entry>
1437       <entry><type>oid</type></entry>
1438       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
1439       <entry>
1440        The OID of the namespace that contains this relation
1441       </entry>
1442      </row>
1443
1444      <row>
1445       <entry><structfield>reltype</structfield></entry>
1446       <entry><type>oid</type></entry>
1447       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1448       <entry>
1449        The OID of the data type that corresponds to this table's row type,
1450        if any (zero for indexes, which have no <structname>pg_type</> entry)
1451       </entry>
1452      </row>
1453
1454      <row>
1455       <entry><structfield>reloftype</structfield></entry>
1456       <entry><type>oid</type></entry>
1457       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1458       <entry>
1459        For typed tables, the OID of the underlying composite type,
1460        zero for all other relations
1461       </entry>
1462      </row>
1463
1464      <row>
1465       <entry><structfield>relowner</structfield></entry>
1466       <entry><type>oid</type></entry>
1467       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1468       <entry>Owner of the relation</entry>
1469      </row>
1470
1471      <row>
1472       <entry><structfield>relam</structfield></entry>
1473       <entry><type>oid</type></entry>
1474       <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
1475       <entry>If this is an index, the access method used (B-tree, hash, etc.)</entry>
1476      </row>
1477
1478      <row>
1479       <entry><structfield>relfilenode</structfield></entry>
1480       <entry><type>oid</type></entry>
1481       <entry></entry>
1482       <entry>Name of the on-disk file of this relation; zero means this
1483        is a <quote>mapped</> relation whose disk file name is determined
1484        by low-level state</entry>
1485      </row>
1486
1487      <row>
1488       <entry><structfield>reltablespace</structfield></entry>
1489       <entry><type>oid</type></entry>
1490       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
1491       <entry>
1492        The tablespace in which this relation is stored.  If zero,
1493        the database's default tablespace is implied.  (Not meaningful
1494        if the relation has no on-disk file.)
1495       </entry>
1496      </row>
1497
1498      <row>
1499       <entry><structfield>relpages</structfield></entry>
1500       <entry><type>int4</type></entry>
1501       <entry></entry>
1502       <entry>
1503        Size of the on-disk representation of this table in pages (of size
1504        <symbol>BLCKSZ</symbol>).  This is only an estimate used by the
1505        planner.  It is updated by <command>VACUUM</command>,
1506        <command>ANALYZE</command>, and a few DDL commands such as
1507        <command>CREATE INDEX</command>.
1508       </entry>
1509      </row>
1510
1511      <row>
1512       <entry><structfield>reltuples</structfield></entry>
1513       <entry><type>float4</type></entry>
1514       <entry></entry>
1515       <entry>
1516        Number of rows in the table.  This is only an estimate used by the
1517        planner.  It is updated by <command>VACUUM</command>,
1518        <command>ANALYZE</command>, and a few DDL commands such as
1519        <command>CREATE INDEX</command>.
1520       </entry>
1521      </row>
1522
1523      <row>
1524       <entry><structfield>reltoastrelid</structfield></entry>
1525       <entry><type>oid</type></entry>
1526       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1527       <entry>
1528        OID of the TOAST table associated with this table, 0 if none.  The
1529        TOAST table stores large attributes <quote>out of line</quote> in a
1530        secondary table.
1531       </entry>
1532      </row>
1533
1534      <row>
1535       <entry><structfield>reltoastidxid</structfield></entry>
1536       <entry><type>oid</type></entry>
1537       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1538       <entry>
1539        For a TOAST table, the OID of its index.  0 if not a TOAST table.
1540       </entry>
1541      </row>
1542
1543      <row>
1544       <entry><structfield>relhasindex</structfield></entry>
1545       <entry><type>bool</type></entry>
1546       <entry></entry>
1547       <entry>
1548        True if this is a table and it has (or recently had) any indexes
1549       </entry>
1550      </row>
1551
1552      <row>
1553       <entry><structfield>relisshared</structfield></entry>
1554       <entry><type>bool</type></entry>
1555       <entry></entry>
1556       <entry>
1557        True if this table is shared across all databases in the cluster.  Only
1558        certain system catalogs (such as <structname>pg_database</structname>)
1559        are shared.
1560       </entry>
1561      </row>
1562
1563      <row>
1564       <entry><structfield>relistemp</structfield></entry>
1565       <entry><type>bool</type></entry>
1566       <entry></entry>
1567       <entry>
1568        True if this table is a temporary relation.  If so, only the creating
1569        session can safely access its contents.
1570       </entry>
1571      </row>
1572
1573      <row>
1574       <entry><structfield>relkind</structfield></entry>
1575       <entry><type>char</type></entry>
1576       <entry></entry>
1577       <entry>
1578        <literal>r</> = ordinary table, <literal>i</> = index,
1579        <literal>S</> = sequence, <literal>v</> = view, <literal>c</> =
1580        composite type, <literal>t</> = TOAST
1581        table
1582       </entry>
1583      </row>
1584
1585      <row>
1586       <entry><structfield>relnatts</structfield></entry>
1587       <entry><type>int2</type></entry>
1588       <entry></entry>
1589       <entry>
1590        Number of user columns in the relation (system columns not
1591        counted).  There must be this many corresponding entries in
1592        <structname>pg_attribute</structname>.  See also
1593        <literal>pg_attribute.attnum</literal>.
1594       </entry>
1595      </row>
1596
1597      <row>
1598       <entry><structfield>relchecks</structfield></entry>
1599       <entry><type>int2</type></entry>
1600       <entry></entry>
1601       <entry>
1602        Number of <literal>CHECK</> constraints on the table; see
1603        <link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link> catalog
1604       </entry>
1605      </row>
1606
1607      <row>
1608       <entry><structfield>relhasoids</structfield></entry>
1609       <entry><type>bool</type></entry>
1610       <entry></entry>
1611       <entry>
1612        True if we generate an OID for each row of the relation
1613       </entry>
1614      </row>
1615
1616      <row>
1617       <entry><structfield>relhaspkey</structfield></entry>
1618       <entry><type>bool</type></entry>
1619       <entry></entry>
1620       <entry>
1621        True if the table has (or once had) a primary key
1622       </entry>
1623      </row>
1624
1625      <row>
1626       <entry><structfield>relhasexclusion</structfield></entry>
1627       <entry><type>bool</type></entry>
1628       <entry></entry>
1629       <entry>
1630        For a table, true if the table has (or once had) any exclusion
1631        constraints; for an index, true if the index supports an exclusion
1632        constraint
1633       </entry>
1634      </row>
1635
1636      <row>
1637       <entry><structfield>relhasrules</structfield></entry>
1638       <entry><type>bool</type></entry>
1639       <entry></entry>
1640       <entry>
1641        True if table has (or once had) rules; see
1642        <link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link> catalog
1643       </entry>
1644      </row>
1645
1646      <row>
1647       <entry><structfield>relhastriggers</structfield></entry>
1648       <entry><type>bool</type></entry>
1649       <entry></entry>
1650       <entry>
1651        True if table has (or once had) triggers; see
1652        <link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link> catalog
1653       </entry>
1654      </row>
1655
1656      <row>
1657       <entry><structfield>relhassubclass</structfield></entry>
1658       <entry><type>bool</type></entry>
1659       <entry></entry>
1660       <entry>True if table has (or once had) any inheritance children</entry>
1661      </row>
1662
1663      <row>
1664       <entry><structfield>relfrozenxid</structfield></entry>
1665       <entry><type>xid</type></entry>
1666       <entry></entry>
1667       <entry>
1668        All transaction IDs before this one have been replaced with a permanent
1669        (<quote>frozen</>) transaction ID in this table.  This is used to track
1670        whether the table needs to be vacuumed in order to prevent transaction
1671        ID wraparound or to allow <literal>pg_clog</> to be shrunk.  Zero
1672        (<symbol>InvalidTransactionId</symbol>) if the relation is not a table.
1673       </entry>
1674      </row>
1675
1676      <row>
1677       <entry><structfield>relacl</structfield></entry>
1678       <entry><type>aclitem[]</type></entry>
1679       <entry></entry>
1680       <entry>
1681        Access privileges; see
1682        <xref linkend="sql-grant"> and
1683        <xref linkend="sql-revoke">
1684        for details
1685       </entry>
1686      </row>
1687
1688      <row>
1689       <entry><structfield>reloptions</structfield></entry>
1690       <entry><type>text[]</type></entry>
1691       <entry></entry>
1692       <entry>
1693        Access-method-specific options, as <quote>keyword=value</> strings
1694       </entry>
1695      </row>
1696     </tbody>
1697    </tgroup>
1698   </table>
1699
1700   <para>
1701    Several of the Boolean flags in <structname>pg_class</> are maintained
1702    lazily: they are guaranteed to be true if that's the correct state, but
1703    may not be reset to false immediately when the condition is no longer
1704    true.  For example, <structfield>relhasindex</> is set by
1705    <command>CREATE INDEX</command>, but it is never cleared by
1706    <command>DROP INDEX</command>.  Instead, <command>VACUUM</command> clears
1707    <structfield>relhasindex</> if it finds the table has no indexes.  This
1708    arrangement avoids race conditions and improves concurrency.
1709   </para>
1710  </sect1>
1711
1712  <sect1 id="catalog-pg-constraint">
1713   <title><structname>pg_constraint</structname></title>
1714
1715   <indexterm zone="catalog-pg-constraint">
1716    <primary>pg_constraint</primary>
1717   </indexterm>
1718
1719   <para>
1720    The catalog <structname>pg_constraint</structname> stores check, primary
1721    key, unique, foreign key, and exclusion constraints on tables.
1722    (Column constraints are not treated specially.  Every column constraint is
1723    equivalent to some table constraint.)
1724    Not-null constraints are represented in the <structname>pg_attribute</>
1725    catalog, not here.
1726   </para>
1727
1728   <para>
1729    User-defined constraint triggers (created with <command>CREATE CONSTRAINT
1730    TRIGGER</>) also give rise to an entry in this table.
1731   </para>
1732
1733   <para>
1734    Check constraints on domains are stored here, too.
1735   </para>
1736
1737   <table>
1738    <title><structname>pg_constraint</> Columns</title>
1739
1740    <tgroup cols="4">
1741     <thead>
1742      <row>
1743       <entry>Name</entry>
1744       <entry>Type</entry>
1745       <entry>References</entry>
1746       <entry>Description</entry>
1747      </row>
1748     </thead>
1749
1750     <tbody>
1751      <row>
1752       <entry><structfield>conname</structfield></entry>
1753       <entry><type>name</type></entry>
1754       <entry></entry>
1755       <entry>Constraint name (not necessarily unique!)</entry>
1756      </row>
1757
1758      <row>
1759       <entry><structfield>connamespace</structfield></entry>
1760       <entry><type>oid</type></entry>
1761       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
1762       <entry>
1763        The OID of the namespace that contains this constraint
1764       </entry>
1765      </row>
1766
1767      <row>
1768       <entry><structfield>contype</structfield></entry>
1769       <entry><type>char</type></entry>
1770       <entry></entry>
1771       <entry>
1772         <literal>c</> = check constraint,
1773         <literal>f</> = foreign key constraint,
1774         <literal>p</> = primary key constraint,
1775         <literal>u</> = unique constraint,
1776         <literal>t</> = constraint trigger,
1777         <literal>x</> = exclusion constraint
1778       </entry>
1779      </row>
1780
1781      <row>
1782       <entry><structfield>condeferrable</structfield></entry>
1783       <entry><type>bool</type></entry>
1784       <entry></entry>
1785       <entry>Is the constraint deferrable?</entry>
1786      </row>
1787
1788      <row>
1789       <entry><structfield>condeferred</structfield></entry>
1790       <entry><type>bool</type></entry>
1791       <entry></entry>
1792       <entry>Is the constraint deferred by default?</entry>
1793      </row>
1794
1795      <row>
1796       <entry><structfield>conrelid</structfield></entry>
1797       <entry><type>oid</type></entry>
1798       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1799       <entry>The table this constraint is on; 0 if not a table constraint</entry>
1800      </row>
1801
1802      <row>
1803       <entry><structfield>contypid</structfield></entry>
1804       <entry><type>oid</type></entry>
1805       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1806       <entry>The domain this constraint is on; 0 if not a domain constraint</entry>
1807      </row>
1808
1809      <row>
1810       <entry><structfield>conindid</structfield></entry>
1811       <entry><type>oid</type></entry>
1812       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1813       <entry>The index supporting this constraint, if it's a unique, primary
1814        key, foreign key, or exclusion constraint; else 0</entry>
1815      </row>
1816
1817      <row>
1818       <entry><structfield>confrelid</structfield></entry>
1819       <entry><type>oid</type></entry>
1820       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1821       <entry>If a foreign key, the referenced table; else 0</entry>
1822      </row>
1823
1824      <row>
1825       <entry><structfield>confupdtype</structfield></entry>
1826       <entry><type>char</type></entry>
1827       <entry></entry>
1828       <entry>Foreign key update action code:
1829             <literal>a</> = no action,
1830             <literal>r</> = restrict,
1831             <literal>c</> = cascade,
1832             <literal>n</> = set null,
1833             <literal>d</> = set default
1834           </entry>
1835      </row>
1836
1837      <row>
1838       <entry><structfield>confdeltype</structfield></entry>
1839       <entry><type>char</type></entry>
1840       <entry></entry>
1841       <entry>Foreign key deletion action code:
1842             <literal>a</> = no action,
1843             <literal>r</> = restrict,
1844             <literal>c</> = cascade,
1845             <literal>n</> = set null,
1846             <literal>d</> = set default
1847           </entry>
1848      </row>
1849
1850      <row>
1851       <entry><structfield>confmatchtype</structfield></entry>
1852       <entry><type>char</type></entry>
1853       <entry></entry>
1854       <entry>Foreign key match type:
1855             <literal>f</> = full,
1856             <literal>p</> = partial,
1857             <literal>u</> = simple (unspecified)
1858           </entry>
1859      </row>
1860
1861      <row>
1862       <entry><structfield>conislocal</structfield></entry>
1863       <entry><type>bool</type></entry>
1864       <entry></entry>
1865       <entry>
1866        This constraint is defined locally for the relation.  Note that a
1867        constraint can be locally defined and inherited simultaneously.
1868       </entry>
1869      </row>
1870
1871      <row>
1872       <entry><structfield>coninhcount</structfield></entry>
1873       <entry><type>int4</type></entry>
1874       <entry></entry>
1875       <entry>
1876        The number of direct inheritance ancestors this constraint has.
1877        A constraint with
1878        a nonzero number of ancestors cannot be dropped nor renamed.
1879       </entry>
1880      </row>
1881
1882      <row>
1883       <entry><structfield>conkey</structfield></entry>
1884       <entry><type>int2[]</type></entry>
1885       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
1886       <entry>If a table constraint (including foreign keys, but not constraint
1887        triggers), list of the constrained columns</entry>
1888      </row>
1889
1890      <row>
1891       <entry><structfield>confkey</structfield></entry>
1892       <entry><type>int2[]</type></entry>
1893       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
1894       <entry>If a foreign key, list of the referenced columns</entry>
1895      </row>
1896
1897      <row>
1898       <entry><structfield>conpfeqop</structfield></entry>
1899       <entry><type>oid[]</type></entry>
1900       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1901       <entry>If a foreign key, list of the equality operators for PK = FK comparisons</entry>
1902      </row>
1903
1904      <row>
1905       <entry><structfield>conppeqop</structfield></entry>
1906       <entry><type>oid[]</type></entry>
1907       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1908       <entry>If a foreign key, list of the equality operators for PK = PK comparisons</entry>
1909      </row>
1910
1911      <row>
1912       <entry><structfield>conffeqop</structfield></entry>
1913       <entry><type>oid[]</type></entry>
1914       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1915       <entry>If a foreign key, list of the equality operators for FK = FK comparisons</entry>
1916      </row>
1917
1918      <row>
1919       <entry><structfield>conexclop</structfield></entry>
1920       <entry><type>oid[]</type></entry>
1921       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1922       <entry>If an exclusion constraint, list of the per-column exclusion operators</entry>
1923      </row>
1924
1925      <row>
1926       <entry><structfield>conbin</structfield></entry>
1927       <entry><type>text</type></entry>
1928       <entry></entry>
1929       <entry>If a check constraint, an internal representation of the expression</entry>
1930      </row>
1931
1932      <row>
1933       <entry><structfield>consrc</structfield></entry>
1934       <entry><type>text</type></entry>
1935       <entry></entry>
1936       <entry>If a check constraint, a human-readable representation of the expression</entry>
1937      </row>
1938     </tbody>
1939    </tgroup>
1940   </table>
1941
1942   <para>
1943    In the case of an exclusion constraint, <structfield>conkey</structfield>
1944    is only useful for constraint elements that are simple column references.
1945    For other cases, a zero appears in <structfield>conkey</structfield>
1946    and the associated index must be consulted to discover the expression
1947    that is constrained.  (<structfield>conkey</structfield> thus has the
1948    same contents as <structname>pg_index</>.<structfield>indkey</> for the
1949    index.)
1950   </para>
1951
1952   <note>
1953    <para>
1954     <structfield>consrc</structfield> is not updated when referenced objects
1955     change; for example, it won't track renaming of columns.  Rather than
1956     relying on this field, it's best to use <function>pg_get_constraintdef()</>
1957     to extract the definition of a check constraint.
1958    </para>
1959   </note>
1960
1961   <note>
1962    <para>
1963     <literal>pg_class.relchecks</literal> needs to agree with the
1964     number of check-constraint entries found in this table for each
1965     relation.  Also, <literal>pg_class.relhasexclusion</literal> must
1966     be true if there are any exclusion-constraint entries for the relation.
1967    </para>
1968   </note>
1969
1970  </sect1>
1971
1972  <sect1 id="catalog-pg-conversion">
1973   <title><structname>pg_conversion</structname></title>
1974
1975   <indexterm zone="catalog-pg-conversion">
1976    <primary>pg_conversion</primary>
1977   </indexterm>
1978
1979   <para>
1980    The catalog <structname>pg_conversion</structname> describes the
1981    available encoding conversion procedures.  See
1982    <xref linkend="sql-createconversion">
1983    for more information.
1984   </para>
1985
1986   <table>
1987    <title><structname>pg_conversion</> Columns</title>
1988
1989    <tgroup cols="4">
1990     <thead>
1991      <row>
1992       <entry>Name</entry>
1993       <entry>Type</entry>
1994       <entry>References</entry>
1995       <entry>Description</entry>
1996      </row>
1997     </thead>
1998
1999     <tbody>
2000      <row>
2001       <entry><structfield>conname</structfield></entry>
2002       <entry><type>name</type></entry>
2003       <entry></entry>
2004       <entry>Conversion name (unique within a namespace)</entry>
2005      </row>
2006
2007      <row>
2008       <entry><structfield>connamespace</structfield></entry>
2009       <entry><type>oid</type></entry>
2010       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
2011       <entry>
2012        The OID of the namespace that contains this conversion
2013       </entry>
2014      </row>
2015
2016      <row>
2017       <entry><structfield>conowner</structfield></entry>
2018       <entry><type>oid</type></entry>
2019       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2020       <entry>Owner of the conversion</entry>
2021      </row>
2022
2023      <row>
2024       <entry><structfield>conforencoding</structfield></entry>
2025       <entry><type>int4</type></entry>
2026       <entry></entry>
2027       <entry>Source encoding ID</entry>
2028      </row>
2029
2030      <row>
2031       <entry><structfield>contoencoding</structfield></entry>
2032       <entry><type>int4</type></entry>
2033       <entry></entry>
2034       <entry>Destination encoding ID</entry>
2035      </row>
2036
2037      <row>
2038       <entry><structfield>conproc</structfield></entry>
2039       <entry><type>regproc</type></entry>
2040       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2041       <entry>Conversion procedure</entry>
2042      </row>
2043
2044      <row>
2045       <entry><structfield>condefault</structfield></entry>
2046       <entry><type>bool</type></entry>
2047       <entry></entry>
2048       <entry>True if this is the default conversion</entry>
2049      </row>
2050
2051     </tbody>
2052    </tgroup>
2053   </table>
2054
2055  </sect1>
2056
2057  <sect1 id="catalog-pg-database">
2058   <title><structname>pg_database</structname></title>
2059
2060   <indexterm zone="catalog-pg-database">
2061    <primary>pg_database</primary>
2062   </indexterm>
2063
2064   <para>
2065    The catalog <structname>pg_database</structname> stores information about
2066    the available databases.  Databases are created with the <xref
2067    linkend="sql-createdatabase"> command.
2068    Consult <xref linkend="managing-databases"> for details about the meaning
2069    of some of the parameters.
2070   </para>
2071
2072   <para>
2073    Unlike most system catalogs, <structname>pg_database</structname>
2074    is shared across all databases of a cluster: there is only one
2075    copy of <structname>pg_database</structname> per cluster, not
2076    one per database.
2077   </para>
2078
2079   <table>
2080    <title><structname>pg_database</> Columns</title>
2081
2082    <tgroup cols="4">
2083     <thead>
2084      <row>
2085       <entry>Name</entry>
2086       <entry>Type</entry>
2087       <entry>References</entry>
2088       <entry>Description</entry>
2089      </row>
2090     </thead>
2091
2092     <tbody>
2093      <row>
2094       <entry><structfield>datname</structfield></entry>
2095       <entry><type>name</type></entry>
2096       <entry></entry>
2097       <entry>Database name</entry>
2098      </row>
2099
2100      <row>
2101       <entry><structfield>datdba</structfield></entry>
2102       <entry><type>oid</type></entry>
2103       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2104       <entry>Owner of the database, usually the user who created it</entry>
2105      </row>
2106
2107      <row>
2108       <entry><structfield>encoding</structfield></entry>
2109       <entry><type>int4</type></entry>
2110       <entry></entry>
2111       <entry>Character encoding for this database
2112           (<function>pg_encoding_to_char()</function> can translate
2113            this number to the encoding name)</entry>
2114      </row>
2115
2116      <row>
2117       <entry><structfield>datcollate</structfield></entry>
2118       <entry><type>name</type></entry>
2119       <entry></entry>
2120       <entry>LC_COLLATE for this database</entry>
2121      </row>
2122
2123      <row>
2124       <entry><structfield>datctype</structfield></entry>
2125       <entry><type>name</type></entry>
2126       <entry></entry>
2127       <entry>LC_CTYPE for this database</entry>
2128      </row>
2129
2130      <row>
2131       <entry><structfield>datistemplate</structfield></entry>
2132       <entry><type>bool</type></entry>
2133       <entry></entry>
2134       <entry>
2135        If true then this database can be used in the
2136        <literal>TEMPLATE</literal> clause of <command>CREATE
2137        DATABASE</command> to create a new database as a clone of
2138        this one
2139       </entry>
2140      </row>
2141
2142      <row>
2143       <entry><structfield>datallowconn</structfield></entry>
2144       <entry><type>bool</type></entry>
2145       <entry></entry>
2146       <entry>
2147        If false then no one can connect to this database.  This is
2148        used to protect the <literal>template0</> database from being altered.
2149       </entry>
2150      </row>
2151
2152      <row>
2153       <entry><structfield>datconnlimit</structfield></entry>
2154       <entry><type>int4</type></entry>
2155       <entry></entry>
2156       <entry>
2157        Sets maximum number of concurrent connections that can be made
2158        to this database.  -1 means no limit.
2159       </entry>
2160      </row>
2161
2162      <row>
2163       <entry><structfield>datlastsysoid</structfield></entry>
2164       <entry><type>oid</type></entry>
2165       <entry></entry>
2166       <entry>
2167        Last system OID in the database; useful
2168        particularly to <application>pg_dump</application>
2169       </entry>
2170      </row>
2171
2172      <row>
2173       <entry><structfield>datfrozenxid</structfield></entry>
2174       <entry><type>xid</type></entry>
2175       <entry></entry>
2176       <entry>
2177        All transaction IDs before this one have been replaced with a permanent
2178        (<quote>frozen</>) transaction ID in this database.  This is used to
2179        track whether the database needs to be vacuumed in order to prevent
2180        transaction ID wraparound or to allow <literal>pg_clog</> to be shrunk.
2181        It is the minimum of the per-table
2182        <structname>pg_class</>.<structfield>relfrozenxid</> values.
2183       </entry>
2184      </row>
2185
2186      <row>
2187       <entry><structfield>dattablespace</structfield></entry>
2188       <entry><type>oid</type></entry>
2189       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
2190       <entry>
2191        The default tablespace for the database.
2192        Within this database, all tables for which
2193        <structname>pg_class</>.<structfield>reltablespace</> is zero
2194        will be stored in this tablespace; in particular, all the non-shared
2195        system catalogs will be there.
2196       </entry>
2197      </row>
2198
2199      <row>
2200       <entry><structfield>datacl</structfield></entry>
2201       <entry><type>aclitem[]</type></entry>
2202       <entry></entry>
2203       <entry>
2204        Access privileges; see
2205        <xref linkend="sql-grant"> and
2206        <xref linkend="sql-revoke">
2207        for details
2208       </entry>
2209      </row>
2210     </tbody>
2211    </tgroup>
2212   </table>
2213  </sect1>
2214
2215
2216  <sect1 id="catalog-pg-db-role-setting">
2217   <title><structname>pg_db_role_setting</structname></title>
2218
2219   <indexterm zone="catalog-pg-db-role-setting">
2220    <primary>pg_db_role_setting</primary>
2221   </indexterm>
2222
2223   <para>
2224    The catalog <structname>pg_db_role_setting</structname> records the default
2225    values that have been set for run-time configuration variables,
2226    for each role and database combination.
2227   </para>
2228
2229   <para>
2230    Unlike most system catalogs, <structname>pg_db_role_setting</structname>
2231    is shared across all databases of a cluster: there is only one
2232    copy of <structname>pg_db_role_setting</structname> per cluster, not
2233    one per database.
2234   </para>
2235
2236   <table>
2237    <title><structname>pg_db_role_setting</> Columns</title>
2238
2239    <tgroup cols="4">
2240     <thead>
2241      <row>
2242       <entry>Name</entry>
2243       <entry>Type</entry>
2244       <entry>References</entry>
2245       <entry>Description</entry>
2246      </row>
2247     </thead>
2248
2249     <tbody>
2250      <row>
2251       <entry><structfield>setdatabase</structfield></entry>
2252       <entry><type>oid</type></entry>
2253       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
2254       <entry>The OID of the database the setting is applicable to, or zero if not database-specific</entry>
2255      </row>
2256
2257      <row>
2258       <entry><structfield>setrole</structfield></entry>
2259       <entry><type>oid</type></entry>
2260       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2261       <entry>The OID of the role the setting is applicable to, or zero if not role-specific</entry>
2262      </row>
2263
2264      <row>
2265       <entry><structfield>setconfig</structfield></entry>
2266       <entry><type>text[]</type></entry>
2267       <entry></entry>
2268       <entry>Defaults for run-time configuration variables</entry>
2269      </row>
2270     </tbody>
2271    </tgroup>
2272   </table>
2273  </sect1>
2274
2275
2276  <sect1 id="catalog-pg-default-acl">
2277   <title><structname>pg_default_acl</structname></title>
2278
2279   <indexterm zone="catalog-pg-default-acl">
2280    <primary>pg_default_acl</primary>
2281   </indexterm>
2282
2283   <para>
2284    The catalog <structname>pg_default_acl</> stores initial
2285    privileges to be assigned to newly created objects.
2286   </para>
2287
2288   <table>
2289    <title><structname>pg_default_acl</> Columns</title>
2290
2291    <tgroup cols="4">
2292     <thead>
2293      <row>
2294       <entry>Name</entry>
2295       <entry>Type</entry>
2296       <entry>References</entry>
2297       <entry>Description</entry>
2298      </row>
2299     </thead>
2300
2301     <tbody>
2302      <row>
2303       <entry><structfield>defaclrole</structfield></entry>
2304       <entry><type>oid</type></entry>
2305       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2306       <entry>The OID of the role associated with this entry</entry>
2307      </row>
2308
2309      <row>
2310       <entry><structfield>defaclnamespace</structfield></entry>
2311       <entry><type>oid</type></entry>
2312       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
2313       <entry>The OID of the namespace associated with this entry,
2314        or 0 if none</entry>
2315      </row>
2316
2317      <row>
2318       <entry><structfield>defaclobjtype</structfield></entry>
2319       <entry><type>char</type></entry>
2320       <entry></entry>
2321       <entry>
2322        Type of object this entry is for:
2323        <literal>r</> = relation (table, view),
2324        <literal>S</> = sequence,
2325        <literal>f</> = function
2326       </entry>
2327      </row>
2328
2329      <row>
2330       <entry><structfield>defaclacl</structfield></entry>
2331       <entry><type>aclitem[]</type></entry>
2332       <entry></entry>
2333       <entry>
2334        Access privileges that this type of object should have on creation
2335       </entry>
2336      </row>
2337     </tbody>
2338    </tgroup>
2339   </table>
2340
2341   <para>
2342    A <structname>pg_default_acl</> entry shows the initial privileges to
2343    be assigned to an object belonging to the indicated user.  There are
2344    currently two types of entry: <quote>global</> entries with
2345    <structfield>defaclnamespace</> = 0, and <quote>per-schema</> entries
2346    that reference a particular schema.  If a global entry is present then
2347    it <emphasis>overrides</> the normal hard-wired default privileges
2348    for the object type.  A per-schema entry, if present, represents privileges
2349    to be <emphasis>added to</> the global or hard-wired default privileges.
2350   </para>
2351
2352   <para>
2353    Note that when an ACL entry in another catalog is null, it is taken
2354    to represent the hard-wired default privileges for its object,
2355    <emphasis>not</> whatever might be in <structname>pg_default_acl</>
2356    at the moment.  <structname>pg_default_acl</> is only consulted during
2357    object creation.
2358   </para>
2359
2360  </sect1>
2361
2362
2363  <sect1 id="catalog-pg-depend">
2364   <title><structname>pg_depend</structname></title>
2365
2366   <indexterm zone="catalog-pg-depend">
2367    <primary>pg_depend</primary>
2368   </indexterm>
2369
2370   <para>
2371    The catalog <structname>pg_depend</structname> records the dependency
2372    relationships between database objects.  This information allows
2373    <command>DROP</> commands to find which other objects must be dropped
2374    by <command>DROP CASCADE</> or prevent dropping in the <command>DROP
2375    RESTRICT</> case.
2376   </para>
2377
2378   <para>
2379    See also <link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link>,
2380    which performs a similar function for dependencies involving objects
2381    that are shared across a database cluster.
2382   </para>
2383
2384   <table>
2385    <title><structname>pg_depend</> Columns</title>
2386
2387    <tgroup cols="4">
2388     <thead>
2389      <row>
2390       <entry>Name</entry>
2391       <entry>Type</entry>
2392       <entry>References</entry>
2393       <entry>Description</entry>
2394      </row>
2395     </thead>
2396
2397     <tbody>
2398      <row>
2399       <entry><structfield>classid</structfield></entry>
2400       <entry><type>oid</type></entry>
2401       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2402       <entry>The OID of the system catalog the dependent object is in</entry>
2403      </row>
2404
2405      <row>
2406       <entry><structfield>objid</structfield></entry>
2407       <entry><type>oid</type></entry>
2408       <entry>any OID column</entry>
2409       <entry>The OID of the specific dependent object</entry>
2410      </row>
2411
2412      <row>
2413       <entry><structfield>objsubid</structfield></entry>
2414       <entry><type>int4</type></entry>
2415       <entry></entry>
2416       <entry>
2417        For a table column, this is the column number (the
2418        <structfield>objid</> and <structfield>classid</> refer to the
2419        table itself).  For all other object types, this column is
2420        zero.
2421       </entry>
2422      </row>
2423
2424      <row>
2425       <entry><structfield>refclassid</structfield></entry>
2426       <entry><type>oid</type></entry>
2427       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2428       <entry>The OID of the system catalog the referenced object is in</entry>
2429      </row>
2430
2431      <row>
2432       <entry><structfield>refobjid</structfield></entry>
2433       <entry><type>oid</type></entry>
2434       <entry>any OID column</entry>
2435       <entry>The OID of the specific referenced object</entry>
2436      </row>
2437
2438      <row>
2439       <entry><structfield>refobjsubid</structfield></entry>
2440       <entry><type>int4</type></entry>
2441       <entry></entry>
2442       <entry>
2443        For a table column, this is the column number (the
2444        <structfield>refobjid</> and <structfield>refclassid</> refer
2445        to the table itself).  For all other object types, this column
2446        is zero.
2447       </entry>
2448      </row>
2449
2450      <row>
2451       <entry><structfield>deptype</structfield></entry>
2452       <entry><type>char</type></entry>
2453       <entry></entry>
2454       <entry>
2455        A code defining the specific semantics of this dependency relationship; see text
2456       </entry>
2457      </row>
2458
2459     </tbody>
2460    </tgroup>
2461   </table>
2462
2463   <para>
2464    In all cases, a <structname>pg_depend</structname> entry indicates that the
2465    referenced object cannot be dropped without also dropping the dependent
2466    object.  However, there are several subflavors identified by
2467    <structfield>deptype</>:
2468
2469    <variablelist>
2470     <varlistentry>
2471      <term><symbol>DEPENDENCY_NORMAL</> (<literal>n</>)</term>
2472      <listitem>
2473       <para>
2474        A normal relationship between separately-created objects.  The
2475        dependent object can be dropped without affecting the
2476        referenced object.  The referenced object can only be dropped
2477        by specifying <literal>CASCADE</>, in which case the dependent
2478        object is dropped, too.  Example: a table column has a normal
2479        dependency on its data type.
2480       </para>
2481      </listitem>
2482     </varlistentry>
2483
2484     <varlistentry>
2485      <term><symbol>DEPENDENCY_AUTO</> (<literal>a</>)</term>
2486      <listitem>
2487       <para>
2488        The dependent object can be dropped separately from the
2489        referenced object, and should be automatically dropped
2490        (regardless of <literal>RESTRICT</> or <literal>CASCADE</>
2491        mode) if the referenced object is dropped.  Example: a named
2492        constraint on a table is made autodependent on the table, so
2493        that it will go away if the table is dropped.
2494       </para>
2495      </listitem>
2496     </varlistentry>
2497
2498     <varlistentry>
2499      <term><symbol>DEPENDENCY_INTERNAL</> (<literal>i</>)</term>
2500      <listitem>
2501       <para>
2502        The dependent object was created as part of creation of the
2503        referenced object, and is really just a part of its internal
2504        implementation.  A <command>DROP</> of the dependent object
2505        will be disallowed outright (we'll tell the user to issue a
2506        <command>DROP</> against the referenced object, instead).  A
2507        <command>DROP</> of the referenced object will be propagated
2508        through to drop the dependent object whether
2509        <command>CASCADE</> is specified or not.  Example: a trigger
2510        that's created to enforce a foreign-key constraint is made
2511        internally dependent on the constraint's
2512        <structname>pg_constraint</> entry.
2513       </para>
2514      </listitem>
2515     </varlistentry>
2516
2517     <varlistentry>
2518      <term><symbol>DEPENDENCY_PIN</> (<literal>p</>)</term>
2519      <listitem>
2520       <para>
2521        There is no dependent object; this type of entry is a signal
2522        that the system itself depends on the referenced object, and so
2523        that object must never be deleted.  Entries of this type are
2524        created only by <command>initdb</command>.  The columns for the
2525        dependent object contain zeroes.
2526       </para>
2527      </listitem>
2528     </varlistentry>
2529    </variablelist>
2530
2531    Other dependency flavors might be needed in future.
2532   </para>
2533
2534  </sect1>
2535
2536
2537  <sect1 id="catalog-pg-description">
2538   <title><structname>pg_description</structname></title>
2539
2540   <indexterm zone="catalog-pg-description">
2541    <primary>pg_description</primary>
2542   </indexterm>
2543
2544   <para>
2545    The catalog <structname>pg_description</> stores optional descriptions
2546    (comments) for each database object.  Descriptions can be manipulated
2547    with the <xref linkend="sql-comment"> command and viewed with
2548    <application>psql</application>'s <literal>\d</literal> commands.
2549    Descriptions of many built-in system objects are provided in the initial
2550    contents of <structname>pg_description</structname>.
2551   </para>
2552
2553   <para>
2554    See also <link linkend="catalog-pg-shdescription"><structname>pg_shdescription</structname></link>,
2555    which performs a similar function for descriptions involving objects that
2556    are shared across a database cluster.
2557   </para>
2558
2559   <table>
2560    <title><structname>pg_description</> Columns</title>
2561
2562    <tgroup cols="4">
2563     <thead>
2564      <row>
2565       <entry>Name</entry>
2566       <entry>Type</entry>
2567       <entry>References</entry>
2568       <entry>Description</entry>
2569      </row>
2570     </thead>
2571
2572     <tbody>
2573      <row>
2574       <entry><structfield>objoid</structfield></entry>
2575       <entry><type>oid</type></entry>
2576       <entry>any OID column</entry>
2577       <entry>The OID of the object this description pertains to</entry>
2578      </row>
2579
2580      <row>
2581       <entry><structfield>classoid</structfield></entry>
2582       <entry><type>oid</type></entry>
2583       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2584       <entry>The OID of the system catalog this object appears in</entry>
2585      </row>
2586
2587      <row>
2588       <entry><structfield>objsubid</structfield></entry>
2589       <entry><type>int4</type></entry>
2590       <entry></entry>
2591       <entry>
2592        For a comment on a table column, this is the column number (the
2593        <structfield>objoid</> and <structfield>classoid</> refer to
2594        the table itself).  For all other object types, this column is
2595        zero.
2596       </entry>
2597      </row>
2598
2599      <row>
2600       <entry><structfield>description</structfield></entry>
2601       <entry><type>text</type></entry>
2602       <entry></entry>
2603       <entry>Arbitrary text that serves as the description of this object</entry>
2604      </row>
2605     </tbody>
2606    </tgroup>
2607   </table>
2608
2609  </sect1>
2610
2611
2612  <sect1 id="catalog-pg-enum">
2613   <title><structname>pg_enum</structname></title>
2614
2615   <indexterm zone="catalog-pg-enum">
2616    <primary>pg_enum</primary>
2617   </indexterm>
2618
2619   <para>
2620    The <structname>pg_enum</structname> catalog contains entries
2621    matching enum types to their associated values and labels. The
2622    internal representation of a given enum value is actually the OID
2623    of its associated row in <structname>pg_enum</structname>.  The
2624    OIDs for a particular enum type are guaranteed to be ordered in
2625    the way the type should sort, but there is no guarantee about the
2626    ordering of OIDs of unrelated enum types.
2627   </para>
2628
2629   <table>
2630    <title><structname>pg_enum</> Columns</title>
2631
2632    <tgroup cols="4">
2633     <thead>
2634      <row>
2635       <entry>Name</entry>
2636       <entry>Type</entry>
2637       <entry>References</entry>
2638       <entry>Description</entry>
2639      </row>
2640     </thead>
2641
2642     <tbody>
2643      <row>
2644       <entry><structfield>enumtypid</structfield></entry>
2645       <entry><type>oid</type></entry>
2646       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
2647       <entry>The OID of the <structname>pg_type</> entry owning this enum value</entry>
2648      </row>
2649
2650      <row>
2651       <entry><structfield>enumlabel</structfield></entry>
2652       <entry><type>name</type></entry>
2653       <entry></entry>
2654       <entry>The textual label for this enum value</entry>
2655      </row>
2656     </tbody>
2657    </tgroup>
2658   </table>
2659  </sect1>
2660
2661
2662  <sect1 id="catalog-pg-foreign-data-wrapper">
2663   <title><structname>pg_foreign_data_wrapper</structname></title>
2664
2665   <indexterm zone="catalog-pg-foreign-data-wrapper">
2666    <primary>pg_foreign_data_wrapper</primary>
2667   </indexterm>
2668
2669   <para>
2670    The catalog <structname>pg_foreign_data_wrapper</structname> stores
2671    foreign-data wrapper definitions.  A foreign-data wrapper is the
2672    mechanism by which external data, residing on foreign servers, is
2673    accessed.
2674   </para>
2675
2676   <table>
2677    <title><structname>pg_foreign_data_wrapper</> Columns</title>
2678
2679    <tgroup cols="4">
2680     <thead>
2681      <row>
2682       <entry>Name</entry>
2683       <entry>Type</entry>
2684       <entry>References</entry>
2685       <entry>Description</entry>
2686      </row>
2687     </thead>
2688
2689     <tbody>
2690      <row>
2691       <entry><structfield>fdwname</structfield></entry>
2692       <entry><type>name</type></entry>
2693       <entry></entry>
2694       <entry>Name of the foreign-data wrapper</entry>
2695      </row>
2696
2697      <row>
2698       <entry><structfield>fdwowner</structfield></entry>
2699       <entry><type>oid</type></entry>
2700       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2701       <entry>Owner of the foreign-data wrapper</entry>
2702      </row>
2703
2704      <row>
2705       <entry><structfield>fdwvalidator</structfield></entry>
2706       <entry><type>oid</type></entry>
2707       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2708       <entry>
2709        References a validator function that is responsible for
2710        checking the validity of the generic options given to the
2711        foreign-data wrapper, as well as to foreign servers and user
2712        mappings using the foreign-data wrapper.  Zero if no validator
2713        is provided.
2714       </entry>
2715      </row>
2716
2717      <row>
2718       <entry><structfield>fdwacl</structfield></entry>
2719       <entry><type>aclitem[]</type></entry>
2720       <entry></entry>
2721       <entry>
2722        Access privileges; see
2723        <xref linkend="sql-grant"> and
2724        <xref linkend="sql-revoke">
2725        for details
2726       </entry>
2727      </row>
2728
2729      <row>
2730       <entry><structfield>fdwoptions</structfield></entry>
2731       <entry><type>text[]</type></entry>
2732       <entry></entry>
2733       <entry>
2734        Foreign-data wrapper specific options, as <quote>keyword=value</> strings
2735       </entry>
2736      </row>
2737     </tbody>
2738    </tgroup>
2739   </table>
2740  </sect1>
2741
2742
2743  <sect1 id="catalog-pg-foreign-server">
2744   <title><structname>pg_foreign_server</structname></title>
2745
2746   <indexterm zone="catalog-pg-foreign-server">
2747    <primary>pg_foreign_server</primary>
2748   </indexterm>
2749
2750   <para>
2751    The catalog <structname>pg_foreign_server</structname> stores
2752    foreign server definitions.  A foreign server describes the
2753    connection to a remote server, managing external data.  Foreign
2754    servers are accessed via foreign-data wrappers.
2755   </para>
2756
2757   <table>
2758    <title><structname>pg_foreign_server</> Columns</title>
2759
2760    <tgroup cols="4">
2761     <thead>
2762      <row>
2763       <entry>Name</entry>
2764       <entry>Type</entry>
2765       <entry>References</entry>
2766       <entry>Description</entry>
2767      </row>
2768     </thead>
2769
2770     <tbody>
2771      <row>
2772       <entry><structfield>srvname</structfield></entry>
2773       <entry><type>name</type></entry>
2774       <entry></entry>
2775       <entry>Name of the foreign server</entry>
2776      </row>
2777
2778      <row>
2779       <entry><structfield>srvowner</structfield></entry>
2780       <entry><type>oid</type></entry>
2781       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2782       <entry>Owner of the foreign server</entry>
2783      </row>
2784
2785      <row>
2786       <entry><structfield>srvfdw</structfield></entry>
2787       <entry><type>oid</type></entry>
2788       <entry><literal><link linkend="catalog-pg-foreign-data-wrapper"><structname>pg_foreign_data_wrapper</structname></link>.oid</literal></entry>
2789       <entry>The OID of the foreign-data wrapper of this foreign server</entry>
2790      </row>
2791
2792      <row>
2793       <entry><structfield>srvtype</structfield></entry>
2794       <entry><type>text</type></entry>
2795       <entry></entry>
2796       <entry>Type of the server (optional)</entry>
2797      </row>
2798
2799      <row>
2800       <entry><structfield>srvversion</structfield></entry>
2801       <entry><type>text</type></entry>
2802       <entry></entry>
2803       <entry>Version of the server (optional)</entry>
2804      </row>
2805
2806      <row>
2807       <entry><structfield>srvacl</structfield></entry>
2808       <entry><type>aclitem[]</type></entry>
2809       <entry></entry>
2810       <entry>
2811        Access privileges; see
2812        <xref linkend="sql-grant"> and
2813        <xref linkend="sql-revoke">
2814        for details
2815       </entry>
2816      </row>
2817
2818      <row>
2819       <entry><structfield>srvoptions</structfield></entry>
2820       <entry><type>text[]</type></entry>
2821       <entry></entry>
2822       <entry>
2823        Foreign server specific options, as <quote>keyword=value</> strings
2824       </entry>
2825      </row>
2826     </tbody>
2827    </tgroup>
2828   </table>
2829  </sect1>
2830
2831
2832  <sect1 id="catalog-pg-index">
2833   <title><structname>pg_index</structname></title>
2834
2835   <indexterm zone="catalog-pg-index">
2836    <primary>pg_index</primary>
2837   </indexterm>
2838
2839   <para>
2840    The catalog <structname>pg_index</structname> contains part of the information
2841    about indexes.  The rest is mostly in
2842    <structname>pg_class</structname>.
2843   </para>
2844
2845   <table>
2846    <title><structname>pg_index</> Columns</title>
2847
2848    <tgroup cols="4">
2849     <thead>
2850      <row>
2851       <entry>Name</entry>
2852       <entry>Type</entry>
2853       <entry>References</entry>
2854       <entry>Description</entry>
2855      </row>
2856     </thead>
2857
2858     <tbody>
2859      <row>
2860       <entry><structfield>indexrelid</structfield></entry>
2861       <entry><type>oid</type></entry>
2862       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2863       <entry>The OID of the <structname>pg_class</> entry for this index</entry>
2864      </row>
2865
2866      <row>
2867       <entry><structfield>indrelid</structfield></entry>
2868       <entry><type>oid</type></entry>
2869       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2870       <entry>The OID of the <structname>pg_class</> entry for the table this index is for</entry>
2871      </row>
2872
2873      <row>
2874       <entry><structfield>indnatts</structfield></entry>
2875       <entry><type>int2</type></entry>
2876       <entry></entry>
2877       <entry>The number of columns in the index (duplicates
2878       <literal>pg_class.relnatts</literal>)</entry>
2879      </row>
2880
2881      <row>
2882       <entry><structfield>indisunique</structfield></entry>
2883       <entry><type>bool</type></entry>
2884       <entry></entry>
2885       <entry>If true, this is a unique index</entry>
2886      </row>
2887
2888      <row>
2889       <entry><structfield>indisprimary</structfield></entry>
2890       <entry><type>bool</type></entry>
2891       <entry></entry>
2892       <entry>If true, this index represents the primary key of the table
2893       (<structfield>indisunique</> should always be true when this is true)</entry>
2894      </row>
2895
2896      <row>
2897       <entry><structfield>indimmediate</structfield></entry>
2898       <entry><type>bool</type></entry>
2899       <entry></entry>
2900       <entry>If true, the uniqueness check is enforced immediately on insertion
2901       (<structfield>indisunique</> should always be true when this is true)</entry>
2902      </row>
2903
2904      <row>
2905       <entry><structfield>indisclustered</structfield></entry>
2906       <entry><type>bool</type></entry>
2907       <entry></entry>
2908       <entry>If true, the table was last clustered on this index</entry>
2909      </row>
2910
2911      <row>
2912       <entry><structfield>indisvalid</structfield></entry>
2913       <entry><type>bool</type></entry>
2914       <entry></entry>
2915       <entry>
2916        If true, the index is currently valid for queries.  False means the
2917        index is possibly incomplete: it must still be modified by
2918        <command>INSERT</>/<command>UPDATE</> operations, but it cannot safely
2919        be used for queries. If it is unique, the uniqueness property is not
2920        true either.
2921       </entry>
2922      </row>
2923
2924      <row>
2925       <entry><structfield>indcheckxmin</structfield></entry>
2926       <entry><type>bool</type></entry>
2927       <entry></entry>
2928       <entry>
2929        If true, queries must not use the index until the <structfield>xmin</>
2930        of this <structname>pg_index</> row is below their <symbol>TransactionXmin</symbol>
2931        event horizon, because the table may contain broken HOT chains with
2932        incompatible rows that they can see
2933       </entry>
2934      </row>
2935
2936      <row>
2937       <entry><structfield>indisready</structfield></entry>
2938       <entry><type>bool</type></entry>
2939       <entry></entry>
2940       <entry>
2941        If true, the index is currently ready for inserts.  False means the
2942        index must be ignored by <command>INSERT</>/<command>UPDATE</>
2943        operations.
2944       </entry>
2945      </row>
2946
2947      <row>
2948       <entry><structfield>indkey</structfield></entry>
2949       <entry><type>int2vector</type></entry>
2950       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
2951       <entry>
2952        This is an array of <structfield>indnatts</structfield> values that
2953        indicate which table columns this index indexes.  For example a value
2954        of <literal>1 3</literal> would mean that the first and the third table
2955        columns make up the index key.  A zero in this array indicates that the
2956        corresponding index attribute is an expression over the table columns,
2957        rather than a simple column reference.
2958       </entry>
2959      </row>
2960
2961      <row>
2962       <entry><structfield>indclass</structfield></entry>
2963       <entry><type>oidvector</type></entry>
2964       <entry><literal><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.oid</literal></entry>
2965       <entry>
2966        For each column in the index key, this contains the OID of
2967        the operator class to use.  See
2968        <link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link> for details.
2969       </entry>
2970      </row>
2971
2972      <row>
2973       <entry><structfield>indoption</structfield></entry>
2974       <entry><type>int2vector</type></entry>
2975       <entry></entry>
2976       <entry>
2977        This is an array of <structfield>indnatts</structfield> values that
2978        store per-column flag bits.  The meaning of the bits is defined by
2979        the index's access method.
2980       </entry>
2981      </row>
2982
2983      <row>
2984       <entry><structfield>indexprs</structfield></entry>
2985       <entry><type>text</type></entry>
2986       <entry></entry>
2987       <entry>
2988        Expression trees (in <function>nodeToString()</function>
2989        representation) for index attributes that are not simple column
2990        references.  This is a list with one element for each zero
2991        entry in <structfield>indkey</>.  Null if all index attributes
2992        are simple references.
2993       </entry>
2994      </row>
2995
2996      <row>
2997       <entry><structfield>indpred</structfield></entry>
2998       <entry><type>text</type></entry>
2999       <entry></entry>
3000       <entry>
3001        Expression tree (in <function>nodeToString()</function>
3002        representation) for partial index predicate.  Null if not a
3003        partial index.
3004       </entry>
3005      </row>
3006     </tbody>
3007    </tgroup>
3008   </table>
3009
3010  </sect1>
3011
3012
3013  <sect1 id="catalog-pg-inherits">
3014   <title><structname>pg_inherits</structname></title>
3015
3016   <indexterm zone="catalog-pg-inherits">
3017    <primary>pg_inherits</primary>
3018   </indexterm>
3019
3020   <para>
3021    The catalog <structname>pg_inherits</> records information about
3022    table inheritance hierarchies.  There is one entry for each direct
3023    child table in the database.  (Indirect inheritance can be determined
3024    by following chains of entries.)
3025   </para>
3026
3027   <table>
3028    <title><structname>pg_inherits</> Columns</title>
3029
3030    <tgroup cols="4">
3031     <thead>
3032      <row>
3033       <entry>Name</entry>
3034       <entry>Type</entry>
3035       <entry>References</entry>
3036       <entry>Description</entry>
3037      </row>
3038     </thead>
3039
3040     <tbody>
3041      <row>
3042       <entry><structfield>inhrelid</structfield></entry>
3043       <entry><type>oid</type></entry>
3044       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3045       <entry>
3046        The OID of the child table
3047       </entry>
3048      </row>
3049
3050      <row>
3051       <entry><structfield>inhparent</structfield></entry>
3052       <entry><type>oid</type></entry>
3053       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3054       <entry>
3055        The OID of the parent table
3056       </entry>
3057      </row>
3058
3059      <row>
3060       <entry><structfield>inhseqno</structfield></entry>
3061       <entry><type>int4</type></entry>
3062       <entry></entry>
3063       <entry>
3064        If there is more than one direct parent for a child table (multiple
3065        inheritance), this number tells the order in which the
3066        inherited columns are to be arranged.  The count starts at 1.
3067       </entry>
3068      </row>
3069     </tbody>
3070    </tgroup>
3071   </table>
3072
3073  </sect1>
3074
3075
3076  <sect1 id="catalog-pg-language">
3077   <title><structname>pg_language</structname></title>
3078
3079   <indexterm zone="catalog-pg-language">
3080    <primary>pg_language</primary>
3081   </indexterm>
3082
3083   <para>
3084    The catalog <structname>pg_language</structname> registers
3085    languages in which you can write functions or stored procedures.
3086    See <xref linkend="sql-createlanguage">
3087    and <xref linkend="xplang"> for more information about language handlers.
3088   </para>
3089
3090   <table>
3091    <title><structname>pg_language</> Columns</title>
3092
3093    <tgroup cols="4">
3094     <thead>
3095      <row>
3096       <entry>Name</entry>
3097       <entry>Type</entry>
3098       <entry>References</entry>
3099       <entry>Description</entry>
3100      </row>
3101     </thead>
3102
3103     <tbody>
3104      <row>
3105       <entry><structfield>lanname</structfield></entry>
3106       <entry><type>name</type></entry>
3107       <entry></entry>
3108       <entry>Name of the language</entry>
3109      </row>
3110
3111      <row>
3112       <entry><structfield>lanowner</structfield></entry>
3113       <entry><type>oid</type></entry>
3114       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3115       <entry>Owner of the language</entry>
3116      </row>
3117
3118      <row>
3119       <entry><structfield>lanispl</structfield></entry>
3120       <entry><type>bool</type></entry>
3121       <entry></entry>
3122       <entry>
3123        This is false for internal languages (such as
3124        <acronym>SQL</acronym>) and true for user-defined languages.
3125        Currently, <application>pg_dump</application> still uses this
3126        to determine which languages need to be dumped, but this might be
3127        replaced by a different mechanism in the future.
3128       </entry>
3129      </row>
3130
3131      <row>
3132       <entry><structfield>lanpltrusted</structfield></entry>
3133       <entry><type>bool</type></entry>
3134       <entry></entry>
3135       <entry>
3136        True if this is a trusted language, which means that it is believed
3137        not to grant access to anything outside the normal SQL execution
3138        environment.  Only superusers can create functions in untrusted
3139        languages.
3140       </entry>
3141      </row>
3142
3143      <row>
3144       <entry><structfield>lanplcallfoid</structfield></entry>
3145       <entry><type>oid</type></entry>
3146       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3147       <entry>
3148        For noninternal languages this references the language
3149        handler, which is a special function that is responsible for
3150        executing all functions that are written in the particular
3151        language
3152       </entry>
3153      </row>
3154
3155      <row>
3156       <entry><structfield>laninline</structfield></entry>
3157       <entry><type>oid</type></entry>
3158       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3159       <entry>
3160        This references a function that is responsible for executing
3161        <quote>inline</> anonymous code blocks
3162        (<xref linkend="sql-do"> blocks).
3163        Zero if inline blocks are not supported.
3164       </entry>
3165      </row>
3166
3167      <row>
3168       <entry><structfield>lanvalidator</structfield></entry>
3169       <entry><type>oid</type></entry>
3170       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3171       <entry>
3172        This references a language validator function that is responsible
3173        for checking the syntax and validity of new functions when they
3174        are created.  Zero if no validator is provided.
3175       </entry>
3176      </row>
3177
3178      <row>
3179       <entry><structfield>lanacl</structfield></entry>
3180       <entry><type>aclitem[]</type></entry>
3181       <entry></entry>
3182       <entry>
3183        Access privileges; see
3184        <xref linkend="sql-grant"> and
3185        <xref linkend="sql-revoke">
3186        for details
3187       </entry>
3188      </row>
3189     </tbody>
3190    </tgroup>
3191   </table>
3192
3193  </sect1>
3194
3195
3196  <sect1 id="catalog-pg-largeobject">
3197   <title><structname>pg_largeobject</structname></title>
3198
3199   <indexterm zone="catalog-pg-largeobject">
3200    <primary>pg_largeobject</primary>
3201   </indexterm>
3202
3203   <para>
3204    The catalog <structname>pg_largeobject</structname> holds the data making up
3205    <quote>large objects</quote>.  A large object is identified by an OID
3206    assigned when it is created.  Each large object is broken into
3207    segments or <quote>pages</> small enough to be conveniently stored as rows
3208    in <structname>pg_largeobject</structname>.
3209    The amount of data per page is defined to be <symbol>LOBLKSIZE</> (which is currently
3210    <literal>BLCKSZ/4</>, or typically 2 kB).
3211   </para>
3212
3213   <para>
3214    Prior to <productname>PostgreSQL</> 9.0, there was no permission structure
3215    associated with large objects.  As a result,
3216    <structname>pg_largeobject</structname> was publicly readable and could be
3217    used to obtain the OIDs (and contents) of all large objects in the system.
3218    This is no longer the case; use
3219    <link linkend="catalog-pg-largeobject-metadata"><structname>pg_largeobject_metadata</></link>
3220    to obtain a list of large object OIDs.
3221   </para>
3222
3223   <table>
3224    <title><structname>pg_largeobject</> Columns</title>
3225
3226    <tgroup cols="4">
3227     <thead>
3228      <row>
3229       <entry>Name</entry>
3230       <entry>Type</entry>
3231       <entry>References</entry>
3232       <entry>Description</entry>
3233      </row>
3234     </thead>
3235
3236     <tbody>
3237      <row>
3238       <entry><structfield>loid</structfield></entry>
3239       <entry><type>oid</type></entry>
3240       <entry><literal><link linkend="catalog-pg-largeobject-metadata"><structname>pg_largeobject_metadata</structname></link>.oid</literal></entry>
3241       <entry>Identifier of the large object that includes this page</entry>
3242      </row>
3243
3244      <row>
3245       <entry><structfield>pageno</structfield></entry>
3246       <entry><type>int4</type></entry>
3247       <entry></entry>
3248       <entry>Page number of this page within its large object
3249       (counting from zero)</entry>
3250      </row>
3251
3252      <row>
3253       <entry><structfield>data</structfield></entry>
3254       <entry><type>bytea</type></entry>
3255       <entry></entry>
3256       <entry>
3257        Actual data stored in the large object.
3258        This will never be more than <symbol>LOBLKSIZE</> bytes and might be less.
3259       </entry>
3260      </row>
3261     </tbody>
3262    </tgroup>
3263   </table>
3264
3265   <para>
3266    Each row of <structname>pg_largeobject</structname> holds data
3267    for one page of a large object, beginning at
3268    byte offset (<literal>pageno * LOBLKSIZE</>) within the object.  The implementation
3269    allows sparse storage: pages might be missing, and might be shorter than
3270    <literal>LOBLKSIZE</> bytes even if they are not the last page of the object.
3271    Missing regions within a large object read as zeroes.
3272   </para>
3273
3274  </sect1>
3275
3276  <sect1 id="catalog-pg-largeobject-metadata">
3277   <title><structname>pg_largeobject_metadata</structname></title>
3278
3279   <indexterm zone="catalog-pg-largeobject-metadata">
3280    <primary>pg_largeobject_metadata</primary>
3281   </indexterm>
3282
3283   <para>
3284    The catalog <structname>pg_largeobject_metadata</structname>
3285    holds metadata associated with large objects.  The actual large object
3286    data is stored in
3287    <link linkend="catalog-pg-largeobject"><structname>pg_largeobject</></link>.
3288   </para>
3289
3290   <table>
3291    <title><structname>pg_largeobject_metadata</> Columns</title>
3292
3293    <tgroup cols="4">
3294     <thead>
3295      <row>
3296       <entry>Name</entry>
3297       <entry>Type</entry>
3298       <entry>References</entry>
3299       <entry>Description</entry>
3300      </row>
3301     </thead>
3302
3303     <tbody>
3304      <row>
3305       <entry><structfield>lomowner</structfield></entry>
3306       <entry><type>oid</type></entry>
3307       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3308       <entry>Owner of the large object</entry>
3309      </row>
3310
3311      <row>
3312       <entry><structfield>lomacl</structfield></entry>
3313       <entry><type>aclitem[]</type></entry>
3314       <entry></entry>
3315       <entry>
3316        Access privileges; see
3317        <xref linkend="sql-grant"> and
3318        <xref linkend="sql-revoke">
3319        for details
3320       </entry>
3321      </row>
3322
3323     </tbody>
3324    </tgroup>
3325   </table>
3326  </sect1>
3327
3328  <sect1 id="catalog-pg-namespace">
3329   <title><structname>pg_namespace</structname></title>
3330
3331   <indexterm zone="catalog-pg-namespace">
3332    <primary>pg_namespace</primary>
3333   </indexterm>
3334
3335   <para>
3336    The catalog <structname>pg_namespace</> stores namespaces.
3337    A namespace is the structure underlying SQL schemas: each namespace
3338    can have a separate collection of relations, types, etc. without name
3339    conflicts.
3340   </para>
3341
3342   <table>
3343    <title><structname>pg_namespace</> Columns</title>
3344
3345    <tgroup cols="4">
3346     <thead>
3347      <row>
3348       <entry>Name</entry>
3349       <entry>Type</entry>
3350       <entry>References</entry>
3351       <entry>Description</entry>
3352      </row>
3353     </thead>
3354
3355     <tbody>
3356      <row>
3357       <entry><structfield>nspname</structfield></entry>
3358       <entry><type>name</type></entry>
3359       <entry></entry>
3360       <entry>Name of the namespace</entry>
3361      </row>
3362
3363      <row>
3364       <entry><structfield>nspowner</structfield></entry>
3365       <entry><type>oid</type></entry>
3366       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3367       <entry>Owner of the namespace</entry>
3368      </row>
3369
3370      <row>
3371       <entry><structfield>nspacl</structfield></entry>
3372       <entry><type>aclitem[]</type></entry>
3373       <entry></entry>
3374       <entry>
3375        Access privileges; see
3376        <xref linkend="sql-grant"> and
3377        <xref linkend="sql-revoke">
3378        for details
3379       </entry>
3380      </row>
3381     </tbody>
3382    </tgroup>
3383   </table>
3384
3385  </sect1>
3386
3387
3388  <sect1 id="catalog-pg-opclass">
3389   <title><structname>pg_opclass</structname></title>
3390
3391   <indexterm zone="catalog-pg-opclass">
3392    <primary>pg_opclass</primary>
3393   </indexterm>
3394
3395   <para>
3396    The catalog <structname>pg_opclass</structname> defines
3397    index access method operator classes.  Each operator class defines
3398    semantics for index columns of a particular data type and a particular
3399    index access method.  An operator class essentially specifies that a
3400    particular operator family is applicable to a particular indexable column
3401    data type.  The set of operators from the family that are actually usable
3402    with the indexed column are whichever ones accept the column's data type
3403    as their lefthand input.
3404   </para>
3405
3406   <para>
3407    Operator classes are described at length in <xref linkend="xindex">.
3408   </para>
3409
3410   <table>
3411    <title><structname>pg_opclass</> Columns</title>
3412
3413    <tgroup cols="4">
3414     <thead>
3415      <row>
3416       <entry>Name</entry>
3417       <entry>Type</entry>
3418       <entry>References</entry>
3419       <entry>Description</entry>
3420      </row>
3421     </thead>
3422     <tbody>
3423
3424      <row>
3425       <entry><structfield>opcmethod</structfield></entry>
3426       <entry><type>oid</type></entry>
3427       <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
3428       <entry>Index access method operator class is for</entry>
3429      </row>
3430
3431      <row>
3432       <entry><structfield>opcname</structfield></entry>
3433       <entry><type>name</type></entry>
3434       <entry></entry>
3435       <entry>Name of this operator class</entry>
3436      </row>
3437
3438      <row>
3439       <entry><structfield>opcnamespace</structfield></entry>
3440       <entry><type>oid</type></entry>
3441       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3442       <entry>Namespace of this operator class</entry>
3443      </row>
3444
3445      <row>
3446       <entry><structfield>opcowner</structfield></entry>
3447       <entry><type>oid</type></entry>
3448       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3449       <entry>Owner of the operator class</entry>
3450      </row>
3451
3452      <row>
3453       <entry><structfield>opcfamily</structfield></entry>
3454       <entry><type>oid</type></entry>
3455       <entry><literal><link linkend="catalog-pg-opfamily"><structname>pg_opfamily</structname></link>.oid</literal></entry>
3456       <entry>Operator family containing the operator class</entry>
3457      </row>
3458
3459      <row>
3460       <entry><structfield>opcintype</structfield></entry>
3461       <entry><type>oid</type></entry>
3462       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3463       <entry>Data type that the operator class indexes</entry>
3464      </row>
3465
3466      <row>
3467       <entry><structfield>opcdefault</structfield></entry>
3468       <entry><type>bool</type></entry>
3469       <entry></entry>
3470       <entry>True if this operator class is the default for <structfield>opcintype</></entry>
3471      </row>
3472
3473      <row>
3474       <entry><structfield>opckeytype</structfield></entry>
3475       <entry><type>oid</type></entry>
3476       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3477       <entry>Type of data stored in index, or zero if same as <structfield>opcintype</></entry>
3478      </row>
3479
3480     </tbody>
3481    </tgroup>
3482   </table>
3483
3484   <para>
3485    An operator class's <structfield>opcmethod</> must match the
3486    <structname>opfmethod</> of its containing operator family.
3487    Also, there must be no more than one <structname>pg_opclass</structname>
3488    row having <structname>opcdefault</> true for any given combination of
3489    <structname>opcmethod</> and <structname>opcintype</>.
3490   </para>
3491
3492  </sect1>
3493
3494
3495  <sect1 id="catalog-pg-operator">
3496   <title><structname>pg_operator</structname></title>
3497
3498   <indexterm zone="catalog-pg-operator">
3499    <primary>pg_operator</primary>
3500   </indexterm>
3501
3502   <para>
3503    The catalog <structname>pg_operator</> stores information about operators.
3504    See <xref linkend="sql-createoperator">
3505    and <xref linkend="xoper"> for more information.
3506   </para>
3507
3508   <table>
3509    <title><structname>pg_operator</> Columns</title>
3510
3511    <tgroup cols="4">
3512     <thead>
3513      <row>
3514       <entry>Name</entry>
3515       <entry>Type</entry>
3516       <entry>References</entry>
3517       <entry>Description</entry>
3518      </row>
3519     </thead>
3520
3521     <tbody>
3522      <row>
3523       <entry><structfield>oprname</structfield></entry>
3524       <entry><type>name</type></entry>
3525       <entry></entry>
3526       <entry>Name of the operator</entry>
3527      </row>
3528
3529      <row>
3530       <entry><structfield>oprnamespace</structfield></entry>
3531       <entry><type>oid</type></entry>
3532       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3533       <entry>
3534        The OID of the namespace that contains this operator
3535       </entry>
3536      </row>
3537
3538      <row>
3539       <entry><structfield>oprowner</structfield></entry>
3540       <entry><type>oid</type></entry>
3541       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3542       <entry>Owner of the operator</entry>
3543      </row>
3544
3545      <row>
3546       <entry><structfield>oprkind</structfield></entry>
3547       <entry><type>char</type></entry>
3548       <entry></entry>
3549       <entry>
3550        <literal>b</> = infix (<quote>both</quote>), <literal>l</> = prefix
3551        (<quote>left</quote>), <literal>r</> = postfix (<quote>right</quote>)
3552       </entry>
3553      </row>
3554
3555      <row>
3556       <entry><structfield>oprcanmerge</structfield></entry>
3557       <entry><type>bool</type></entry>
3558       <entry></entry>
3559       <entry>This operator supports merge joins</entry>
3560      </row>
3561
3562      <row>
3563       <entry><structfield>oprcanhash</structfield></entry>
3564       <entry><type>bool</type></entry>
3565       <entry></entry>
3566       <entry>This operator supports hash joins</entry>
3567      </row>
3568
3569      <row>
3570       <entry><structfield>oprleft</structfield></entry>
3571       <entry><type>oid</type></entry>
3572       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3573       <entry>Type of the left operand</entry>
3574      </row>
3575
3576      <row>
3577       <entry><structfield>oprright</structfield></entry>
3578       <entry><type>oid</type></entry>
3579       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3580       <entry>Type of the right operand</entry>
3581      </row>
3582
3583      <row>
3584       <entry><structfield>oprresult</structfield></entry>
3585       <entry><type>oid</type></entry>
3586       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3587       <entry>Type of the result</entry>
3588      </row>
3589
3590      <row>
3591       <entry><structfield>oprcom</structfield></entry>
3592       <entry><type>oid</type></entry>
3593       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3594       <entry>Commutator of this operator, if any</entry>
3595      </row>
3596
3597      <row>
3598       <entry><structfield>oprnegate</structfield></entry>
3599       <entry><type>oid</type></entry>
3600       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3601       <entry>Negator of this operator, if any</entry>
3602      </row>
3603
3604      <row>
3605       <entry><structfield>oprcode</structfield></entry>
3606       <entry><type>regproc</type></entry>
3607       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3608       <entry>Function that implements this operator</entry>
3609      </row>
3610
3611      <row>
3612       <entry><structfield>oprrest</structfield></entry>
3613       <entry><type>regproc</type></entry>
3614       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3615       <entry>Restriction selectivity estimation function for this operator</entry>
3616      </row>
3617
3618      <row>
3619       <entry><structfield>oprjoin</structfield></entry>
3620       <entry><type>regproc</type></entry>
3621       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3622       <entry>Join selectivity estimation function for this operator</entry>
3623      </row>
3624     </tbody>
3625    </tgroup>
3626   </table>
3627
3628   <para>
3629    Unused column contain zeroes. For example, <structfield>oprleft</structfield>
3630    is zero for a prefix operator.
3631   </para>
3632
3633  </sect1>
3634
3635
3636  <sect1 id="catalog-pg-opfamily">
3637   <title><structname>pg_opfamily</structname></title>
3638
3639   <indexterm zone="catalog-pg-opfamily">
3640    <primary>pg_opfamily</primary>
3641   </indexterm>
3642
3643   <para>
3644    The catalog <structname>pg_opfamily</structname> defines operator families.
3645    Each operator family is a collection of operators and associated
3646    support routines that implement the semantics specified for a particular
3647    index access method.  Furthermore, the operators in a family are all
3648    <quote>compatible</>, in a way that is specified by the access method.
3649    The operator family concept allows cross-data-type operators to be used
3650    with indexes and to be reasoned about using knowledge of access method
3651    semantics.
3652   </para>
3653
3654   <para>
3655    Operator families are described at length in <xref linkend="xindex">.
3656   </para>
3657
3658   <table>
3659    <title><structname>pg_opfamily</> Columns</title>
3660
3661    <tgroup cols="4">
3662     <thead>
3663      <row>
3664       <entry>Name</entry>
3665       <entry>Type</entry>
3666       <entry>References</entry>
3667       <entry>Description</entry>
3668      </row>
3669     </thead>
3670     <tbody>
3671
3672      <row>
3673       <entry><structfield>opfmethod</structfield></entry>
3674       <entry><type>oid</type></entry>
3675       <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
3676       <entry>Index access method operator family is for</entry>
3677      </row>
3678
3679      <row>
3680       <entry><structfield>opfname</structfield></entry>
3681       <entry><type>name</type></entry>
3682       <entry></entry>
3683       <entry>Name of this operator family</entry>
3684      </row>
3685
3686      <row>
3687       <entry><structfield>opfnamespace</structfield></entry>
3688       <entry><type>oid</type></entry>
3689       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3690       <entry>Namespace of this operator family</entry>
3691      </row>
3692
3693      <row>
3694       <entry><structfield>opfowner</structfield></entry>
3695       <entry><type>oid</type></entry>
3696       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3697       <entry>Owner of the operator family</entry>
3698      </row>
3699
3700     </tbody>
3701    </tgroup>
3702   </table>
3703
3704   <para>
3705    The majority of the information defining an operator family is not in its
3706    <structname>pg_opfamily</structname> row, but in the associated rows in
3707    <link linkend="catalog-pg-amop"><structname>pg_amop</structname></link>,
3708    <link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link>,
3709    and
3710    <link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.
3711   </para>
3712
3713  </sect1>
3714
3715
3716  <sect1 id="catalog-pg-pltemplate">
3717   <title><structname>pg_pltemplate</structname></title>
3718
3719   <indexterm zone="catalog-pg-pltemplate">
3720    <primary>pg_pltemplate</primary>
3721   </indexterm>
3722
3723   <para>
3724    The catalog <structname>pg_pltemplate</structname> stores
3725    <quote>template</> information for procedural languages.
3726    A template for a language allows the language to be created in a
3727    particular database by a simple <command>CREATE LANGUAGE</> command,
3728    with no need to specify implementation details.
3729   </para>
3730
3731   <para>
3732    Unlike most system catalogs, <structname>pg_pltemplate</structname>
3733    is shared across all databases of a cluster: there is only one
3734    copy of <structname>pg_pltemplate</structname> per cluster, not
3735    one per database.  This allows the information to be accessible in
3736    each database as it is needed.
3737   </para>
3738
3739   <table>
3740    <title><structname>pg_pltemplate</> Columns</title>
3741
3742    <tgroup cols="3">
3743     <thead>
3744      <row>
3745       <entry>Name</entry>
3746       <entry>Type</entry>
3747       <entry>Description</entry>
3748      </row>
3749     </thead>
3750
3751     <tbody>
3752      <row>
3753       <entry><structfield>tmplname</structfield></entry>
3754       <entry><type>name</type></entry>
3755       <entry>Name of the language this template is for</entry>
3756      </row>
3757
3758      <row>
3759       <entry><structfield>tmpltrusted</structfield></entry>
3760       <entry><type>boolean</type></entry>
3761       <entry>True if language is considered trusted</entry>
3762      </row>
3763
3764      <row>
3765       <entry><structfield>tmpldbacreate</structfield></entry>
3766       <entry><type>boolean</type></entry>
3767       <entry>True if language may be created by a database owner</entry>
3768      </row>
3769
3770      <row>
3771       <entry><structfield>tmplhandler</structfield></entry>
3772       <entry><type>text</type></entry>
3773       <entry>Name of call handler function</entry>
3774      </row>
3775
3776      <row>
3777       <entry><structfield>tmplinline</structfield></entry>
3778       <entry><type>text</type></entry>
3779       <entry>Name of anonymous-block handler function, or null if none</entry>
3780      </row>
3781
3782      <row>
3783       <entry><structfield>tmplvalidator</structfield></entry>
3784       <entry><type>text</type></entry>
3785       <entry>Name of validator function, or null if none</entry>
3786      </row>
3787
3788      <row>
3789       <entry><structfield>tmpllibrary</structfield></entry>
3790       <entry><type>text</type></entry>
3791       <entry>Path of shared library that implements language</entry>
3792      </row>
3793
3794      <row>
3795       <entry><structfield>tmplacl</structfield></entry>
3796       <entry><type>aclitem[]</type></entry>
3797       <entry>Access privileges for template (not yet used)</entry>
3798      </row>
3799
3800     </tbody>
3801    </tgroup>
3802   </table>
3803
3804   <para>
3805    There are not currently any commands that manipulate procedural language
3806    templates; to change the built-in information, a superuser must modify
3807    the table using ordinary <command>INSERT</command>, <command>DELETE</command>,
3808    or <command>UPDATE</command> commands.  It is likely that a future
3809    release of <productname>PostgreSQL</productname> will offer
3810    commands to change the entries in a cleaner fashion.
3811   </para>
3812
3813   <para>
3814    When implemented, the <structfield>tmplacl</structfield> field will provide
3815    access control for the template itself (i.e., the right to create a
3816    language using it), not for the languages created from the template.
3817   </para>
3818
3819  </sect1>
3820
3821
3822  <sect1 id="catalog-pg-proc">
3823   <title><structname>pg_proc</structname></title>
3824
3825   <indexterm zone="catalog-pg-proc">
3826    <primary>pg_proc</primary>
3827   </indexterm>
3828
3829   <para>
3830    The catalog <structname>pg_proc</> stores information about functions (or procedures).
3831    See <xref linkend="sql-createfunction">
3832    and <xref linkend="xfunc"> for more information.
3833   </para>
3834
3835   <para>
3836    The table contains data for aggregate functions as well as plain functions.
3837    If <structfield>proisagg</structfield> is true, there should be a matching
3838    row in <structfield>pg_aggregate</structfield>.
3839   </para>
3840
3841   <table>
3842    <title><structname>pg_proc</> Columns</title>
3843
3844    <tgroup cols="4">
3845     <thead>
3846      <row>
3847       <entry>Name</entry>
3848       <entry>Type</entry>
3849       <entry>References</entry>
3850       <entry>Description</entry>
3851      </row>
3852     </thead>
3853
3854     <tbody>
3855      <row>
3856       <entry><structfield>proname</structfield></entry>
3857       <entry><type>name</type></entry>
3858       <entry></entry>
3859       <entry>Name of the function</entry>
3860      </row>
3861
3862      <row>
3863       <entry><structfield>pronamespace</structfield></entry>
3864       <entry><type>oid</type></entry>
3865       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3866       <entry>
3867        The OID of the namespace that contains this function
3868       </entry>
3869      </row>
3870
3871      <row>
3872       <entry><structfield>proowner</structfield></entry>
3873       <entry><type>oid</type></entry>
3874       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3875       <entry>Owner of the function</entry>
3876      </row>
3877
3878      <row>
3879       <entry><structfield>prolang</structfield></entry>
3880       <entry><type>oid</type></entry>
3881       <entry><literal><link linkend="catalog-pg-language"><structname>pg_language</structname></link>.oid</literal></entry>
3882       <entry>Implementation language or call interface of this function</entry>
3883      </row>
3884
3885      <row>
3886       <entry><structfield>procost</structfield></entry>
3887       <entry><type>float4</type></entry>
3888       <entry></entry>
3889       <entry>Estimated execution cost (in units of
3890        <xref linkend="guc-cpu-operator-cost">); if <structfield>proretset</>,
3891        this is cost per row returned</entry>
3892      </row>
3893
3894      <row>
3895       <entry><structfield>prorows</structfield></entry>
3896       <entry><type>float4</type></entry>
3897       <entry></entry>
3898       <entry>Estimated number of result rows (zero if not <structfield>proretset</>)</entry>
3899      </row>
3900
3901      <row>
3902       <entry><structfield>provariadic</structfield></entry>
3903       <entry><type>oid</type></entry>
3904       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3905       <entry>Data type of the variadic array parameter's elements,
3906        or zero if the function does not have a variadic parameter</entry>
3907      </row>
3908
3909      <row>
3910       <entry><structfield>proisagg</structfield></entry>
3911       <entry><type>bool</type></entry>
3912       <entry></entry>
3913       <entry>Function is an aggregate function</entry>
3914      </row>
3915
3916      <row>
3917       <entry><structfield>proiswindow</structfield></entry>
3918       <entry><type>bool</type></entry>
3919       <entry></entry>
3920       <entry>Function is a window function</entry>
3921      </row>
3922
3923      <row>
3924       <entry><structfield>prosecdef</structfield></entry>
3925       <entry><type>bool</type></entry>
3926       <entry></entry>
3927       <entry>Function is a security definer (i.e., a <quote>setuid</>
3928       function)</entry>
3929      </row>
3930
3931      <row>
3932       <entry><structfield>proisstrict</structfield></entry>
3933       <entry><type>bool</type></entry>
3934       <entry></entry>
3935       <entry>
3936        Function returns null if any call argument is null.  In that
3937        case the function won't actually be called at all.  Functions
3938        that are not <quote>strict</quote> must be prepared to handle
3939        null inputs.
3940       </entry>
3941      </row>
3942
3943      <row>
3944       <entry><structfield>proretset</structfield></entry>
3945       <entry><type>bool</type></entry>
3946       <entry></entry>
3947       <entry>Function returns a set (i.e., multiple values of the specified
3948       data type)</entry>
3949      </row>
3950
3951      <row>
3952       <entry><structfield>provolatile</structfield></entry>
3953       <entry><type>char</type></entry>
3954       <entry></entry>
3955       <entry>
3956        <structfield>provolatile</structfield> tells whether the function's
3957        result depends only on its input arguments, or is affected by outside
3958        factors.
3959        It is <literal>i</literal> for <quote>immutable</> functions,
3960        which always deliver the same result for the same inputs.
3961        It is <literal>s</literal> for <quote>stable</> functions,
3962        whose results (for fixed inputs) do not change within a scan.
3963        It is <literal>v</literal> for <quote>volatile</> functions,
3964        whose results might change at any time.  (Use <literal>v</literal> also
3965        for functions with side-effects, so that calls to them cannot get
3966        optimized away.)
3967       </entry>
3968      </row>
3969
3970      <row>
3971       <entry><structfield>pronargs</structfield></entry>
3972       <entry><type>int2</type></entry>
3973       <entry></entry>
3974       <entry>Number of input arguments</entry>
3975      </row>
3976
3977      <row>
3978       <entry><structfield>pronargdefaults</structfield></entry>
3979       <entry><type>int2</type></entry>
3980       <entry></entry>
3981       <entry>Number of arguments that have defaults</entry>
3982      </row>
3983
3984      <row>
3985       <entry><structfield>prorettype</structfield></entry>
3986       <entry><type>oid</type></entry>
3987       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3988       <entry>Data type of the return value</entry>
3989      </row>
3990
3991      <row>
3992       <entry><structfield>proargtypes</structfield></entry>
3993       <entry><type>oidvector</type></entry>
3994       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3995       <entry>
3996        An array with the data types of the function arguments.  This includes
3997        only input arguments (including <literal>INOUT</literal> and
3998        <literal>VARIADIC</> arguments), and thus represents
3999        the call signature of the function.
4000       </entry>
4001      </row>
4002
4003      <row>
4004       <entry><structfield>proallargtypes</structfield></entry>
4005       <entry><type>oid[]</type></entry>
4006       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
4007       <entry>
4008        An array with the data types of the function arguments.  This includes
4009        all arguments (including <literal>OUT</literal> and
4010        <literal>INOUT</literal> arguments); however, if all the
4011        arguments are <literal>IN</literal> arguments, this field will be null.
4012        Note that subscripting is 1-based, whereas for historical reasons
4013        <structfield>proargtypes</> is subscripted from 0.
4014       </entry>
4015      </row>
4016
4017      <row>
4018       <entry><structfield>proargmodes</structfield></entry>
4019       <entry><type>char[]</type></entry>
4020       <entry></entry>
4021       <entry>
4022         An array with the modes of the function arguments, encoded as
4023         <literal>i</literal> for <literal>IN</> arguments,
4024         <literal>o</literal> for <literal>OUT</> arguments,
4025         <literal>b</literal> for <literal>INOUT</> arguments,
4026         <literal>v</literal> for <literal>VARIADIC</> arguments,
4027         <literal>t</literal> for <literal>TABLE</> arguments.
4028         If all the arguments are <literal>IN</literal> arguments,
4029         this field will be null.
4030         Note that subscripts correspond to positions of
4031         <structfield>proallargtypes</> not <structfield>proargtypes</>.
4032       </entry>
4033      </row>
4034
4035      <row>
4036       <entry><structfield>proargnames</structfield></entry>
4037       <entry><type>text[]</type></entry>
4038       <entry></entry>
4039       <entry>
4040         An array with the names of the function arguments.
4041         Arguments without a name are set to empty strings in the array.
4042         If none of the arguments have a name, this field will be null.
4043         Note that subscripts correspond to positions of
4044         <structfield>proallargtypes</> not <structfield>proargtypes</>.
4045       </entry>
4046      </row>
4047
4048      <row>
4049       <entry><structfield>proargdefaults</structfield></entry>
4050       <entry><type>text</type></entry>
4051       <entry></entry>
4052       <entry>
4053        Expression trees (in <function>nodeToString()</function> representation)
4054        for default values.  This is a list with
4055        <structfield>pronargdefaults</> elements, corresponding to the last
4056        <replaceable>N</> <emphasis>input</> arguments (i.e., the last
4057        <replaceable>N</> <structfield>proargtypes</> positions).
4058        If none of the arguments have defaults, this field will be null.
4059       </entry>
4060      </row>
4061
4062      <row>
4063       <entry><structfield>prosrc</structfield></entry>
4064       <entry><type>text</type></entry>
4065       <entry></entry>
4066       <entry>
4067        This tells the function handler how to invoke the function.  It
4068        might be the actual source code of the function for interpreted
4069        languages, a link symbol, a file name, or just about anything
4070        else, depending on the implementation language/call convention.
4071       </entry>
4072      </row>
4073
4074      <row>
4075       <entry><structfield>probin</structfield></entry>
4076       <entry><type>text</type></entry>
4077       <entry></entry>
4078       <entry>
4079        Additional information about how to invoke the function.
4080        Again, the interpretation is language-specific.
4081       </entry>
4082      </row>
4083
4084      <row>
4085       <entry><structfield>proconfig</structfield></entry>
4086       <entry><type>text[]</type></entry>
4087       <entry></entry>
4088       <entry>Function's local settings for run-time configuration variables</entry>
4089      </row>
4090
4091      <row>
4092       <entry><structfield>proacl</structfield></entry>
4093       <entry><type>aclitem[]</type></entry>
4094       <entry></entry>
4095       <entry>
4096        Access privileges; see
4097        <xref linkend="sql-grant"> and
4098        <xref linkend="sql-revoke">
4099        for details
4100       </entry>
4101      </row>
4102     </tbody>
4103    </tgroup>
4104   </table>
4105
4106   <para>
4107    For compiled functions, both built-in and dynamically loaded,
4108    <structfield>prosrc</structfield> contains the function's C-language
4109    name (link symbol).  For all other currently-known language types,
4110    <structfield>prosrc</structfield> contains the function's source
4111    text.  <structfield>probin</structfield> is unused except for
4112    dynamically-loaded C functions, for which it gives the name of the
4113    shared library file containing the function.
4114   </para>
4115
4116  </sect1>
4117
4118  <sect1 id="catalog-pg-rewrite">
4119   <title><structname>pg_rewrite</structname></title>
4120
4121   <indexterm zone="catalog-pg-rewrite">
4122    <primary>pg_rewrite</primary>
4123   </indexterm>
4124
4125   <para>
4126    The catalog <structname>pg_rewrite</structname> stores rewrite rules for tables and views.
4127   </para>
4128
4129   <table>
4130    <title><structname>pg_rewrite</> Columns</title>
4131
4132    <tgroup cols="4">
4133     <thead>
4134      <row>
4135       <entry>Name</entry>
4136       <entry>Type</entry>
4137       <entry>References</entry>
4138       <entry>Description</entry>
4139      </row>
4140     </thead>
4141
4142     <tbody>
4143      <row>
4144       <entry><structfield>rulename</structfield></entry>
4145       <entry><type>name</type></entry>
4146       <entry></entry>
4147       <entry>Rule name</entry>
4148      </row>
4149
4150      <row>
4151       <entry><structfield>ev_class</structfield></entry>
4152       <entry><type>oid</type></entry>
4153       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4154       <entry>The table this rule is for</entry>
4155      </row>
4156
4157      <row>
4158       <entry><structfield>ev_attr</structfield></entry>
4159       <entry><type>int2</type></entry>
4160       <entry></entry>
4161       <entry>The column this rule is for (currently, always zero to
4162       indicate the whole table)</entry>
4163      </row>
4164
4165      <row>
4166       <entry><structfield>ev_type</structfield></entry>
4167       <entry><type>char</type></entry>
4168       <entry></entry>
4169       <entry>
4170        Event type that the rule is for: 1 = <command>SELECT</>, 2 =
4171        <command>UPDATE</>, 3 = <command>INSERT</>, 4 =
4172        <command>DELETE</>
4173       </entry>
4174      </row>
4175
4176      <row>
4177       <entry><structfield>ev_enabled</structfield></entry>
4178       <entry><type>char</type></entry>
4179       <entry></entry>
4180       <entry>
4181        Controls in which <xref linkend="guc-session-replication-role"> modes
4182        the rule fires.
4183        <literal>O</> = rule fires in <quote>origin</> and <quote>local</> modes,
4184        <literal>D</> = rule is disabled,
4185        <literal>R</> = rule fires in <quote>replica</> mode,
4186        <literal>A</> = rule fires always.
4187       </entry>
4188      </row>
4189
4190      <row>
4191       <entry><structfield>is_instead</structfield></entry>
4192       <entry><type>bool</type></entry>
4193       <entry></entry>
4194       <entry>True if the rule is an <literal>INSTEAD</literal> rule</entry>
4195      </row>
4196
4197      <row>
4198       <entry><structfield>ev_qual</structfield></entry>
4199       <entry><type>text</type></entry>
4200       <entry></entry>
4201       <entry>
4202        Expression tree (in the form of a
4203        <function>nodeToString()</function> representation) for the
4204        rule's qualifying condition
4205       </entry>
4206      </row>
4207
4208      <row>
4209       <entry><structfield>ev_action</structfield></entry>
4210       <entry><type>text</type></entry>
4211       <entry></entry>
4212       <entry>
4213        Query tree (in the form of a
4214        <function>nodeToString()</function> representation) for the
4215        rule's action
4216       </entry>
4217      </row>
4218     </tbody>
4219    </tgroup>
4220   </table>
4221
4222   <note>
4223    <para>
4224     <literal>pg_class.relhasrules</literal>
4225     must be true if a table has any rules in this catalog.
4226    </para>
4227   </note>
4228
4229  </sect1>
4230
4231
4232  <sect1 id="catalog-pg-shdepend">
4233   <title><structname>pg_shdepend</structname></title>
4234
4235   <indexterm zone="catalog-pg-shdepend">
4236    <primary>pg_shdepend</primary>
4237   </indexterm>
4238
4239   <para>
4240    The catalog <structname>pg_shdepend</structname> records the
4241    dependency relationships between database objects and shared objects,
4242    such as roles.  This information allows
4243    <productname>PostgreSQL</productname> to ensure that those objects are
4244    unreferenced before attempting to delete them.
4245   </para>
4246
4247   <para>
4248    See also <link linkend="catalog-pg-depend"><structname>pg_depend</structname></link>,
4249    which performs a similar function for dependencies involving objects
4250    within a single database.
4251   </para>
4252
4253   <para>
4254    Unlike most system catalogs, <structname>pg_shdepend</structname>
4255    is shared across all databases of a cluster: there is only one
4256    copy of <structname>pg_shdepend</structname> per cluster, not
4257    one per database.
4258   </para>
4259
4260   <table>
4261    <title><structname>pg_shdepend</> Columns</title>
4262
4263    <tgroup cols="4">
4264     <thead>
4265      <row>
4266       <entry>Name</entry>
4267       <entry>Type</entry>
4268       <entry>References</entry>
4269       <entry>Description</entry>
4270      </row>
4271     </thead>
4272
4273     <tbody>
4274      <row>
4275       <entry><structfield>dbid</structfield></entry>
4276       <entry><type>oid</type></entry>
4277       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
4278       <entry>The OID of the database the dependent object is in,
4279        or zero for a shared object</entry>
4280      </row>
4281
4282      <row>
4283       <entry><structfield>classid</structfield></entry>
4284       <entry><type>oid</type></entry>
4285       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4286       <entry>The OID of the system catalog the dependent object is in</entry>
4287      </row>
4288
4289      <row>
4290       <entry><structfield>objid</structfield></entry>
4291       <entry><type>oid</type></entry>
4292       <entry>any OID column</entry>
4293       <entry>The OID of the specific dependent object</entry>
4294      </row>
4295
4296      <row>
4297       <entry><structfield>objsubid</structfield></entry>
4298       <entry><type>int4</type></entry>
4299       <entry></entry>
4300       <entry>
4301        For a table column, this is the column number (the
4302        <structfield>objid</> and <structfield>classid</> refer to the
4303        table itself).  For all other object types, this column is zero.
4304       </entry>
4305      </row>
4306
4307      <row>
4308       <entry><structfield>refclassid</structfield></entry>
4309       <entry><type>oid</type></entry>
4310       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4311       <entry>The OID of the system catalog the referenced object is in
4312        (must be a shared catalog)</entry>
4313      </row>
4314
4315      <row>
4316       <entry><structfield>refobjid</structfield></entry>
4317       <entry><type>oid</type></entry>
4318       <entry>any OID column</entry>
4319       <entry>The OID of the specific referenced object</entry>
4320      </row>
4321
4322      <row>
4323       <entry><structfield>deptype</structfield></entry>
4324       <entry><type>char</type></entry>
4325       <entry></entry>
4326       <entry>
4327        A code defining the specific semantics of this dependency relationship; see text
4328       </entry>
4329      </row>
4330
4331     </tbody>
4332    </tgroup>
4333   </table>
4334
4335   <para>
4336    In all cases, a <structname>pg_shdepend</structname> entry indicates that
4337    the referenced object cannot be dropped without also dropping the dependent
4338    object.  However, there are several subflavors identified by
4339    <structfield>deptype</>:
4340
4341    <variablelist>
4342     <varlistentry>
4343      <term><symbol>SHARED_DEPENDENCY_OWNER</> (<literal>o</>)</term>
4344      <listitem>
4345       <para>
4346        The referenced object (which must be a role) is the owner of the
4347        dependent object.
4348       </para>
4349      </listitem>
4350     </varlistentry>
4351
4352     <varlistentry>
4353      <term><symbol>SHARED_DEPENDENCY_ACL</> (<literal>a</>)</term>
4354      <listitem>
4355       <para>
4356        The referenced object (which must be a role) is mentioned in the
4357        ACL (access control list, i.e., privileges list) of the
4358        dependent object.  (A <symbol>SHARED_DEPENDENCY_ACL</> entry is
4359        not made for the owner of the object, since the owner will have
4360        a <symbol>SHARED_DEPENDENCY_OWNER</> entry anyway.)
4361       </para>
4362      </listitem>
4363     </varlistentry>
4364
4365     <varlistentry>
4366      <term><symbol>SHARED_DEPENDENCY_PIN</> (<literal>p</>)</term>
4367      <listitem>
4368       <para>
4369        There is no dependent object; this type of entry is a signal
4370        that the system itself depends on the referenced object, and so
4371        that object must never be deleted.  Entries of this type are
4372        created only by <command>initdb</command>.  The columns for the
4373        dependent object contain zeroes.
4374       </para>
4375      </listitem>
4376     </varlistentry>
4377    </variablelist>
4378
4379    Other dependency flavors might be needed in future.  Note in particular
4380    that the current definition only supports roles as referenced objects.
4381   </para>
4382
4383  </sect1>
4384
4385  <sect1 id="catalog-pg-shdescription">
4386   <title><structname>pg_shdescription</structname></title>
4387
4388   <indexterm zone="catalog-pg-shdescription">
4389    <primary>pg_shdescription</primary>
4390   </indexterm>
4391
4392   <para>
4393    The catalog <structname>pg_shdescription</structname> stores optional
4394    descriptions (comments) for shared database objects.  Descriptions can be
4395    manipulated with the <xref linkend="sql-comment"> command and viewed with
4396    <application>psql</application>'s <literal>\d</literal> commands.
4397   </para>
4398
4399   <para>
4400    See also <link linkend="catalog-pg-description"><structname>pg_description</structname></link>,
4401    which performs a similar function for descriptions involving objects
4402    within a single database.
4403   </para>
4404
4405   <para>
4406    Unlike most system catalogs, <structname>pg_shdescription</structname>
4407    is shared across all databases of a cluster: there is only one
4408    copy of <structname>pg_shdescription</structname> per cluster, not
4409    one per database.
4410   </para>
4411
4412   <table>
4413    <title><structname>pg_shdescription</> Columns</title>
4414
4415    <tgroup cols="4">
4416     <thead>
4417      <row>
4418       <entry>Name</entry>
4419       <entry>Type</entry>
4420       <entry>References</entry>
4421       <entry>Description</entry>
4422      </row>
4423     </thead>
4424
4425     <tbody>
4426      <row>
4427       <entry><structfield>objoid</structfield></entry>
4428       <entry><type>oid</type></entry>
4429       <entry>any OID column</entry>
4430       <entry>The OID of the object this description pertains to</entry>
4431      </row>
4432
4433      <row>
4434       <entry><structfield>classoid</structfield></entry>
4435       <entry><type>oid</type></entry>
4436       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4437       <entry>The OID of the system catalog this object appears in</entry>
4438      </row>
4439
4440      <row>
4441       <entry><structfield>description</structfield></entry>
4442       <entry><type>text</type></entry>
4443       <entry></entry>
4444       <entry>Arbitrary text that serves as the description of this object</entry>
4445      </row>
4446     </tbody>
4447    </tgroup>
4448   </table>
4449
4450  </sect1>
4451
4452
4453  <sect1 id="catalog-pg-statistic">
4454   <title><structname>pg_statistic</structname></title>
4455
4456   <indexterm zone="catalog-pg-statistic">
4457    <primary>pg_statistic</primary>
4458   </indexterm>
4459
4460   <para>
4461    The catalog <structname>pg_statistic</structname> stores
4462    statistical data about the contents of the database.  Entries are
4463    created by <xref linkend="sql-analyze">
4464    and subsequently used by the query planner.  Note that all the
4465    statistical data is inherently approximate, even assuming that it
4466    is up-to-date.
4467   </para>
4468
4469   <para>
4470    Normally there is one entry, with <structfield>stainherit</> =
4471    <literal>false</>, for each table column that has been analyzed.
4472    If the table has inheritance children, a second entry with
4473    <structfield>stainherit</> = <literal>true</> is also created.  This row
4474    represents the column's statistics over the inheritance tree, i.e.,
4475    statistics for the data you'd see with
4476    <literal>SELECT <replaceable>column</> FROM <replaceable>table</>*</literal>,
4477    whereas the <structfield>stainherit</> = <literal>false</> row represents
4478    the results of
4479    <literal>SELECT <replaceable>column</> FROM ONLY <replaceable>table</></literal>.
4480   </para>
4481
4482   <para>
4483    <structname>pg_statistic</structname> also stores statistical data about
4484    the values of index expressions.  These are described as if they were
4485    actual data columns; in particular, <structfield>starelid</structfield>
4486    references the index.  No entry is made for an ordinary non-expression
4487    index column, however, since it would be redundant with the entry
4488    for the underlying table column.  Currently, entries for index expressions
4489    always have <structfield>stainherit</> = <literal>false</>.
4490   </para>
4491
4492   <para>
4493    Since different kinds of statistics might be appropriate for different
4494    kinds of data, <structname>pg_statistic</structname> is designed not
4495    to assume very much about what sort of statistics it stores.  Only
4496    extremely general statistics (such as nullness) are given dedicated
4497    columns in <structname>pg_statistic</structname>.  Everything else
4498    is stored in <quote>slots</quote>, which are groups of associated columns
4499    whose content is identified by a code number in one of the slot's columns.
4500    For more information see
4501    <filename>src/include/catalog/pg_statistic.h</filename>.
4502   </para>
4503
4504   <para>
4505    <structname>pg_statistic</structname> should not be readable by the
4506    public, since even statistical information about a table's contents
4507    might be considered sensitive.  (Example: minimum and maximum values
4508    of a salary column might be quite interesting.)
4509    <link linkend="view-pg-stats"><structname>pg_stats</structname></link>
4510    is a publicly readable view on
4511    <structname>pg_statistic</structname> that only exposes information
4512    about those tables that are readable by the current user.
4513   </para>
4514
4515   <table>
4516    <title><structname>pg_statistic</> Columns</title>
4517
4518    <tgroup cols="4">
4519     <thead>
4520      <row>
4521       <entry>Name</entry>
4522       <entry>Type</entry>
4523       <entry>References</entry>
4524       <entry>Description</entry>
4525      </row>
4526     </thead>
4527
4528     <tbody>
4529      <row>
4530       <entry><structfield>starelid</structfield></entry>
4531       <entry><type>oid</type></entry>
4532       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4533       <entry>The table or index that the described column belongs to</entry>
4534      </row>
4535
4536      <row>
4537       <entry><structfield>staattnum</structfield></entry>
4538       <entry><type>int2</type></entry>
4539       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
4540       <entry>The number of the described column</entry>
4541      </row>
4542
4543      <row>
4544       <entry><structfield>stainherit</structfield></entry>
4545       <entry><type>bool</type></entry>
4546       <entry></entry>
4547       <entry>If true, the stats include inheritance child columns, not just the
4548        values in the specified relation</entry>
4549      </row>
4550
4551      <row>
4552       <entry><structfield>stanullfrac</structfield></entry>
4553       <entry><type>float4</type></entry>
4554       <entry></entry>
4555       <entry>The fraction of the column's entries that are null</entry>
4556      </row>
4557
4558      <row>
4559       <entry><structfield>stawidth</structfield></entry>
4560       <entry><type>int4</type></entry>
4561       <entry></entry>
4562       <entry>The average stored width, in bytes, of nonnull entries</entry>
4563      </row>
4564
4565      <row>
4566       <entry><structfield>stadistinct</structfield></entry>
4567       <entry><type>float4</type></entry>
4568       <entry></entry>
4569       <entry>The number of distinct nonnull data values in the column.
4570       A value greater than zero is the actual number of distinct values.
4571       A value less than zero is the negative of a multiplier for the number
4572       of rows in the table; for example, a column in which values appear about
4573       twice on the average could be represented by
4574       <structfield>stadistinct</> = -0.5.
4575       A zero value means the number of distinct values is unknown.
4576       </entry>
4577      </row>
4578
4579      <row>
4580       <entry><structfield>stakind<replaceable>N</></structfield></entry>
4581       <entry><type>int2</type></entry>
4582       <entry></entry>
4583       <entry>
4584        A code number indicating the kind of statistics stored in the
4585        <replaceable>N</>th <quote>slot</quote> of the
4586        <structname>pg_statistic</structname> row.
4587       </entry>
4588      </row>
4589
4590      <row>
4591       <entry><structfield>staop<replaceable>N</></structfield></entry>
4592       <entry><type>oid</type></entry>
4593       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
4594       <entry>
4595        An operator used to derive the statistics stored in the
4596        <replaceable>N</>th <quote>slot</quote>.  For example, a
4597        histogram slot would show the <literal>&lt;</literal> operator
4598        that defines the sort order of the data.
4599       </entry>
4600      </row>
4601
4602      <row>
4603       <entry><structfield>stanumbers<replaceable>N</></structfield></entry>
4604       <entry><type>float4[]</type></entry>
4605       <entry></entry>
4606       <entry>
4607        Numerical statistics of the appropriate kind for the
4608        <replaceable>N</>th <quote>slot</quote>, or null if the slot
4609        kind does not involve numerical values
4610       </entry>
4611      </row>
4612
4613      <row>
4614       <entry><structfield>stavalues<replaceable>N</></structfield></entry>
4615       <entry><type>anyarray</type></entry>
4616       <entry></entry>
4617       <entry>
4618        Column data values of the appropriate kind for the
4619        <replaceable>N</>th <quote>slot</quote>, or null if the slot
4620        kind does not store any data values.  Each array's element
4621        values are actually of the specific column's data type, so there
4622        is no way to define these columns' type more specifically than
4623        <type>anyarray</>.
4624       </entry>
4625      </row>
4626     </tbody>
4627    </tgroup>
4628   </table>
4629
4630  </sect1>
4631
4632
4633  <sect1 id="catalog-pg-tablespace">
4634   <title><structname>pg_tablespace</structname></title>
4635
4636   <indexterm zone="catalog-pg-tablespace">
4637    <primary>pg_tablespace</primary>
4638   </indexterm>
4639
4640   <para>
4641    The catalog <structname>pg_tablespace</structname> stores information
4642    about the available tablespaces.  Tables can be placed in particular
4643    tablespaces to aid administration of disk layout.
4644   </para>
4645
4646   <para>
4647    Unlike most system catalogs, <structname>pg_tablespace</structname>
4648    is shared across all databases of a cluster: there is only one
4649    copy of <structname>pg_tablespace</structname> per cluster, not
4650    one per database.
4651   </para>
4652
4653   <table>
4654    <title><structname>pg_tablespace</> Columns</title>
4655
4656    <tgroup cols="4">
4657     <thead>
4658      <row>
4659       <entry>Name</entry>
4660       <entry>Type</entry>
4661       <entry>References</entry>
4662       <entry>Description</entry>
4663      </row>
4664     </thead>
4665
4666     <tbody>
4667      <row>
4668       <entry><structfield>spcname</structfield></entry>
4669       <entry><type>name</type></entry>
4670       <entry></entry>
4671       <entry>Tablespace name</entry>
4672      </row>
4673
4674      <row>
4675       <entry><structfield>spcowner</structfield></entry>
4676       <entry><type>oid</type></entry>
4677       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4678       <entry>Owner of the tablespace, usually the user who created it</entry>
4679      </row>
4680
4681      <row>
4682       <entry><structfield>spclocation</structfield></entry>
4683       <entry><type>text</type></entry>
4684       <entry></entry>
4685       <entry>Location (directory path) of the tablespace</entry>
4686      </row>
4687
4688      <row>
4689       <entry><structfield>spcacl</structfield></entry>
4690       <entry><type>aclitem[]</type></entry>
4691       <entry></entry>
4692       <entry>
4693        Access privileges; see
4694        <xref linkend="sql-grant"> and
4695        <xref linkend="sql-revoke">
4696        for details
4697       </entry>
4698      </row>
4699
4700      <row>
4701       <entry><structfield>spcoptions</structfield></entry>
4702       <entry><type>text[]</type></entry>
4703       <entry></entry>
4704       <entry>
4705        Tablespace-level options, as <quote>keyword=value</> strings
4706       </entry>
4707      </row>
4708     </tbody>
4709    </tgroup>
4710   </table>
4711  </sect1>
4712
4713
4714  <sect1 id="catalog-pg-trigger">
4715   <title><structname>pg_trigger</structname></title>
4716
4717   <indexterm zone="catalog-pg-trigger">
4718    <primary>pg_trigger</primary>
4719   </indexterm>
4720
4721   <para>
4722    The catalog <structname>pg_trigger</structname> stores triggers on tables.
4723    See <xref linkend="sql-createtrigger">
4724    for more information.
4725   </para>
4726
4727   <table>
4728    <title><structname>pg_trigger</> Columns</title>
4729
4730    <tgroup cols="4">
4731     <thead>
4732      <row>
4733       <entry>Name</entry>
4734       <entry>Type</entry>
4735       <entry>References</entry>
4736       <entry>Description</entry>
4737      </row>
4738     </thead>
4739
4740     <tbody>
4741      <row>
4742       <entry><structfield>tgrelid</structfield></entry>
4743       <entry><type>oid</type></entry>
4744       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4745       <entry>The table this trigger is on</entry>
4746      </row>
4747
4748      <row>
4749       <entry><structfield>tgname</structfield></entry>
4750       <entry><type>name</type></entry>
4751       <entry></entry>
4752       <entry>Trigger name (must be unique among triggers of same table)</entry>
4753      </row>
4754
4755      <row>
4756       <entry><structfield>tgfoid</structfield></entry>
4757       <entry><type>oid</type></entry>
4758       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4759       <entry>The function to be called</entry>
4760      </row>
4761
4762      <row>
4763       <entry><structfield>tgtype</structfield></entry>
4764       <entry><type>int2</type></entry>
4765       <entry></entry>
4766       <entry>Bit mask identifying trigger conditions</entry>
4767      </row>
4768
4769      <row>
4770       <entry><structfield>tgenabled</structfield></entry>
4771       <entry><type>char</type></entry>
4772       <entry></entry>
4773       <entry>
4774        Controls in which <xref linkend="guc-session-replication-role"> modes
4775        the trigger fires.
4776        <literal>O</> = trigger fires in <quote>origin</> and <quote>local</> modes,
4777        <literal>D</> = trigger is disabled,
4778        <literal>R</> = trigger fires in <quote>replica</> mode,
4779        <literal>A</> = trigger fires always.
4780       </entry>
4781      </row>
4782
4783      <row>
4784       <entry><structfield>tgisinternal</structfield></entry>
4785       <entry><type>bool</type></entry>
4786       <entry></entry>
4787       <entry>True if trigger is internally generated (usually, to enforce
4788        the constraint identified by <structfield>tgconstraint</>)</entry>
4789      </row>
4790
4791      <row>
4792       <entry><structfield>tgconstrrelid</structfield></entry>
4793       <entry><type>oid</type></entry>
4794       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4795       <entry>The table referenced by a referential integrity constraint</entry>
4796      </row>
4797
4798      <row>
4799       <entry><structfield>tgconstrindid</structfield></entry>
4800       <entry><type>oid</type></entry>
4801       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4802       <entry>The index supporting a unique, primary key, or referential integrity constraint</entry>
4803      </row>
4804
4805      <row>
4806       <entry><structfield>tgconstraint</structfield></entry>
4807       <entry><type>oid</type></entry>
4808       <entry><literal><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link>.oid</literal></entry>
4809       <entry>The <structname>pg_constraint</> entry associated with the trigger, if any</entry>
4810      </row>
4811
4812      <row>
4813       <entry><structfield>tgdeferrable</structfield></entry>
4814       <entry><type>bool</type></entry>
4815       <entry></entry>
4816       <entry>True if constraint trigger is deferrable</entry>
4817      </row>
4818
4819      <row>
4820       <entry><structfield>tginitdeferred</structfield></entry>
4821       <entry><type>bool</type></entry>
4822       <entry></entry>
4823       <entry>True if constraint trigger is initially deferred</entry>
4824      </row>
4825
4826      <row>
4827       <entry><structfield>tgnargs</structfield></entry>
4828       <entry><type>int2</type></entry>
4829       <entry></entry>
4830       <entry>Number of argument strings passed to trigger function</entry>
4831      </row>
4832
4833      <row>
4834       <entry><structfield>tgattr</structfield></entry>
4835       <entry><type>int2vector</type></entry>
4836       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
4837       <entry>Column numbers, if trigger is column-specific; otherwise an
4838        empty array</entry>
4839      </row>
4840
4841      <row>
4842       <entry><structfield>tgargs</structfield></entry>
4843       <entry><type>bytea</type></entry>
4844       <entry></entry>
4845       <entry>Argument strings to pass to trigger, each NULL-terminated</entry>
4846      </row>
4847
4848      <row>
4849       <entry><structfield>tgqual</structfield></entry>
4850       <entry><type>text</type></entry>
4851       <entry></entry>
4852       <entry>Expression tree (in <function>nodeToString()</function>
4853        representation) for the trigger's <literal>WHEN</> condition, or null
4854        if none</entry>
4855      </row>
4856     </tbody>
4857    </tgroup>
4858   </table>
4859
4860   <para>
4861    Currently, column-specific triggering is supported only for
4862    <literal>UPDATE</> events, and so <structfield>tgattr</> is relevant
4863    only for that event type.  <structfield>tgtype</structfield> might
4864    contain bits for other event types as well, but those are presumed
4865    to be table-wide regardless of what is in <structfield>tgattr</>.
4866   </para>
4867
4868   <note>
4869    <para>
4870     When <structfield>tgconstraint</> is nonzero,
4871     <structfield>tgconstrrelid</>, <structfield>tgconstrindid</>,
4872     <structfield>tgdeferrable</>, and <structfield>tginitdeferred</> are
4873     largely redundant with the referenced <structname>pg_constraint</> entry.
4874     However, it is possible for a non-deferrable trigger to be associated
4875     with a deferrable constraint: foreign key constraints can have some
4876     deferrable and some non-deferrable triggers.
4877    </para>
4878   </note>
4879
4880   <note>
4881    <para>
4882     <literal>pg_class.relhastriggers</literal>
4883     must be true if a table has any triggers in this catalog.
4884    </para>
4885   </note>
4886
4887  </sect1>
4888
4889
4890  <sect1 id="catalog-pg-ts-config">
4891   <title><structname>pg_ts_config</structname></title>
4892
4893   <indexterm zone="catalog-pg-ts-config">
4894    <primary>pg_ts_config</primary>
4895   </indexterm>
4896
4897   <para>
4898    The <structname>pg_ts_config</structname> catalog contains entries
4899    representing text search configurations.  A configuration specifies
4900    a particular text search parser and a list of dictionaries to use
4901    for each of the parser's output token types.  The parser is shown
4902    in the <structname>pg_ts_config</structname> entry, but the
4903    token-to-dictionary mapping is defined by subsidiary entries in <link
4904    linkend="catalog-pg-ts-config-map"><structname>pg_ts_config_map</structname></link>.
4905   </para>
4906
4907   <para>
4908    <productname>PostgreSQL</productname>'s text search features are
4909    described at length in <xref linkend="textsearch">.
4910   </para>
4911
4912   <table>
4913    <title><structname>pg_ts_config</> Columns</title>
4914
4915    <tgroup cols="4">
4916     <thead>
4917      <row>
4918       <entry>Name</entry>
4919       <entry>Type</entry>
4920       <entry>References</entry>
4921       <entry>Description</entry>
4922      </row>
4923     </thead>
4924
4925     <tbody>
4926      <row>
4927       <entry><structfield>cfgname</structfield></entry>
4928       <entry><type>name</type></entry>
4929       <entry></entry>
4930       <entry>Text search configuration name</entry>
4931      </row>
4932
4933      <row>
4934       <entry><structfield>cfgnamespace</structfield></entry>
4935       <entry><type>oid</type></entry>
4936       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4937       <entry>
4938        The OID of the namespace that contains this configuration
4939       </entry>
4940      </row>
4941
4942      <row>
4943       <entry><structfield>cfgowner</structfield></entry>
4944       <entry><type>oid</type></entry>
4945       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4946       <entry>Owner of the configuration</entry>
4947      </row>
4948
4949      <row>
4950       <entry><structfield>cfgparser</structfield></entry>
4951       <entry><type>oid</type></entry>
4952       <entry><literal><link linkend="catalog-pg-ts-parser"><structname>pg_ts_parser</structname></link>.oid</literal></entry>
4953       <entry>The OID of the text search parser for this configuration</entry>
4954      </row>
4955     </tbody>
4956    </tgroup>
4957   </table>
4958  </sect1>
4959
4960
4961  <sect1 id="catalog-pg-ts-config-map">
4962   <title><structname>pg_ts_config_map</structname></title>
4963
4964   <indexterm zone="catalog-pg-ts-config-map">
4965    <primary>pg_ts_config_map</primary>
4966   </indexterm>
4967
4968   <para>
4969    The <structname>pg_ts_config_map</structname> catalog contains entries
4970    showing which text search dictionaries should be consulted, and in
4971    what order, for each output token type of each text search configuration's
4972    parser.
4973   </para>
4974
4975   <para>
4976    <productname>PostgreSQL</productname>'s text search features are
4977    described at length in <xref linkend="textsearch">.
4978   </para>
4979
4980   <table>
4981    <title><structname>pg_ts_config_map</> Columns</title>
4982
4983    <tgroup cols="4">
4984     <thead>
4985      <row>
4986       <entry>Name</entry>
4987       <entry>Type</entry>
4988       <entry>References</entry>
4989       <entry>Description</entry>
4990      </row>
4991     </thead>
4992
4993     <tbody>
4994      <row>
4995       <entry><structfield>mapcfg</structfield></entry>
4996       <entry><type>oid</type></entry>
4997       <entry><literal><link linkend="catalog-pg-ts-config"><structname>pg_ts_config</structname></link>.oid</literal></entry>
4998       <entry>The OID of the <structname>pg_ts_config</> entry owning this map entry</entry>
4999      </row>
5000
5001      <row>
5002       <entry><structfield>maptokentype</structfield></entry>
5003       <entry><type>integer</type></entry>
5004       <entry></entry>
5005       <entry>A token type emitted by the configuration's parser</entry>
5006      </row>
5007
5008      <row>
5009       <entry><structfield>mapseqno</structfield></entry>
5010       <entry><type>integer</type></entry>
5011       <entry></entry>
5012       <entry>Order in which to consult this entry (lower
5013        <structfield>mapseqno</>s first)</entry>
5014      </row>
5015
5016      <row>
5017       <entry><structfield>mapdict</structfield></entry>
5018       <entry><type>oid</type></entry>
5019       <entry><literal><link linkend="catalog-pg-ts-dict"><structname>pg_ts_dict</structname></link>.oid</literal></entry>
5020       <entry>The OID of the text search dictionary to consult</entry>
5021      </row>
5022     </tbody>
5023    </tgroup>
5024   </table>
5025  </sect1>
5026
5027
5028  <sect1 id="catalog-pg-ts-dict">
5029   <title><structname>pg_ts_dict</structname></title>
5030
5031   <indexterm zone="catalog-pg-ts-dict">
5032    <primary>pg_ts_dict</primary>
5033   </indexterm>
5034
5035   <para>
5036    The <structname>pg_ts_dict</structname> catalog contains entries
5037    defining text search dictionaries.  A dictionary depends on a text
5038    search template, which specifies all the implementation functions
5039    needed; the dictionary itself provides values for the user-settable
5040    parameters supported by the template.  This division of labor allows
5041    dictionaries to be created by unprivileged users.  The parameters
5042    are specified by a text string <structfield>dictinitoption</>,
5043    whose format and meaning vary depending on the template.
5044   </para>
5045
5046   <para>
5047    <productname>PostgreSQL</productname>'s text search features are
5048    described at length in <xref linkend="textsearch">.
5049   </para>
5050
5051   <table>
5052    <title><structname>pg_ts_dict</> Columns</title>
5053
5054    <tgroup cols="4">
5055     <thead>
5056      <row>
5057       <entry>Name</entry>
5058       <entry>Type</entry>
5059       <entry>References</entry>
5060       <entry>Description</entry>
5061      </row>
5062     </thead>
5063
5064     <tbody>
5065      <row>
5066       <entry><structfield>dictname</structfield></entry>
5067       <entry><type>name</type></entry>
5068       <entry></entry>
5069       <entry>Text search dictionary name</entry>
5070      </row>
5071
5072      <row>
5073       <entry><structfield>dictnamespace</structfield></entry>
5074       <entry><type>oid</type></entry>
5075       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
5076       <entry>
5077        The OID of the namespace that contains this dictionary
5078       </entry>
5079      </row>
5080
5081      <row>
5082       <entry><structfield>dictowner</structfield></entry>
5083       <entry><type>oid</type></entry>
5084       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
5085       <entry>Owner of the dictionary</entry>
5086      </row>
5087
5088      <row>
5089       <entry><structfield>dicttemplate</structfield></entry>
5090       <entry><type>oid</type></entry>
5091       <entry><literal><link linkend="catalog-pg-ts-template"><structname>pg_ts_template</structname></link>.oid</literal></entry>
5092       <entry>The OID of the text search template for this dictionary</entry>
5093      </row>
5094
5095      <row>
5096       <entry><structfield>dictinitoption</structfield></entry>
5097       <entry><type>text</type></entry>
5098       <entry></entry>
5099       <entry>Initialization option string for the template</entry>
5100      </row>
5101     </tbody>
5102    </tgroup>
5103   </table>
5104  </sect1>
5105
5106
5107  <sect1 id="catalog-pg-ts-parser">
5108   <title><structname>pg_ts_parser</structname></title>
5109
5110   <indexterm zone="catalog-pg-ts-parser">
5111    <primary>pg_ts_parser</primary>
5112   </indexterm>
5113
5114   <para>
5115    The <structname>pg_ts_parser</structname> catalog contains entries
5116    defining text search parsers.  A parser is responsible for splitting
5117    input text into lexemes and assigning a token type to each lexeme.
5118    Since a parser must be implemented by C-language-level functions,
5119    creation of new parsers is restricted to database superusers.
5120   </para>
5121
5122   <para>
5123    <productname>PostgreSQL</productname>'s text search features are
5124    described at length in <xref linkend="textsearch">.
5125   </para>
5126
5127   <table>
5128    <title><structname>pg_ts_parser</> Columns</title>
5129
5130    <tgroup cols="4">
5131     <thead>
5132      <row>
5133       <entry>Name</entry>
5134       <entry>Type</entry>
5135       <entry>References</entry>
5136       <entry>Description</entry>
5137      </row>
5138     </thead>
5139
5140     <tbody>
5141      <row>
5142       <entry><structfield>prsname</structfield></entry>
5143       <entry><type>name</type></entry>
5144       <entry></entry>
5145       <entry>Text search parser name</entry>
5146      </row>
5147
5148      <row>
5149       <entry><structfield>prsnamespace</structfield></entry>
5150       <entry><type>oid</type></entry>
5151       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
5152       <entry>
5153        The OID of the namespace that contains this parser
5154       </entry>
5155      </row>
5156
5157      <row>
5158       <entry><structfield>prsstart</structfield></entry>
5159       <entry><type>regproc</type></entry>
5160       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5161       <entry>OID of the parser's startup function</entry>
5162      </row>
5163
5164      <row>
5165       <entry><structfield>prstoken</structfield></entry>
5166       <entry><type>regproc</type></entry>
5167       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5168       <entry>OID of the parser's next-token function</entry>
5169      </row>
5170
5171      <row>
5172       <entry><structfield>prsend</structfield></entry>
5173       <entry><type>regproc</type></entry>
5174       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5175       <entry>OID of the parser's shutdown function</entry>
5176      </row>
5177
5178      <row>
5179       <entry><structfield>prsheadline</structfield></entry>
5180       <entry><type>regproc</type></entry>
5181       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5182       <entry>OID of the parser's headline function</entry>
5183      </row>
5184
5185      <row>
5186       <entry><structfield>prslextype</structfield></entry>
5187       <entry><type>regproc</type></entry>
5188       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5189       <entry>OID of the parser's lextype function</entry>
5190      </row>
5191     </tbody>
5192    </tgroup>
5193   </table>
5194  </sect1>
5195
5196
5197  <sect1 id="catalog-pg-ts-template">
5198   <title><structname>pg_ts_template</structname></title>
5199
5200   <indexterm zone="catalog-pg-ts-template">
5201    <primary>pg_ts_template</primary>
5202   </indexterm>
5203
5204   <para>
5205    The <structname>pg_ts_template</structname> catalog contains entries
5206    defining text search templates.  A template is the implementation
5207    skeleton for a class of text search dictionaries.
5208    Since a template must be implemented by C-language-level functions,
5209    creation of new templates is restricted to database superusers.
5210   </para>
5211
5212   <para>
5213    <productname>PostgreSQL</productname>'s text search features are
5214    described at length in <xref linkend="textsearch">.
5215   </para>
5216
5217   <table>
5218    <title><structname>pg_ts_template</> Columns</title>
5219
5220    <tgroup cols="4">
5221     <thead>
5222      <row>
5223       <entry>Name</entry>
5224       <entry>Type</entry>
5225       <entry>References</entry>
5226       <entry>Description</entry>
5227      </row>
5228     </thead>
5229
5230     <tbody>
5231      <row>
5232       <entry><structfield>tmplname</structfield></entry>
5233       <entry><type>name</type></entry>
5234       <entry></entry>
5235       <entry>Text search template name</entry>
5236      </row>
5237
5238      <row>
5239       <entry><structfield>tmplnamespace</structfield></entry>
5240       <entry><type>oid</type></entry>
5241       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
5242       <entry>
5243        The OID of the namespace that contains this template
5244       </entry>
5245      </row>
5246
5247      <row>
5248       <entry><structfield>tmplinit</structfield></entry>
5249       <entry><type>regproc</type></entry>
5250       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5251       <entry>OID of the template's initialization function</entry>
5252      </row>
5253
5254      <row>
5255       <entry><structfield>tmpllexize</structfield></entry>
5256       <entry><type>regproc</type></entry>
5257       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5258       <entry>OID of the template's lexize function</entry>
5259      </row>
5260     </tbody>
5261    </tgroup>
5262   </table>
5263  </sect1>
5264
5265
5266  <sect1 id="catalog-pg-type">
5267   <title><structname>pg_type</structname></title>
5268
5269   <indexterm zone="catalog-pg-type">
5270    <primary>pg_type</primary>
5271   </indexterm>
5272
5273   <para>
5274    The catalog <structname>pg_type</structname> stores information about data
5275    types.  Base types and enum types (scalar types) are created with
5276    <xref linkend="sql-createtype">, and
5277    domains with
5278    <xref linkend="sql-createdomain">.
5279    A composite type is automatically created for each table in the database, to
5280    represent the row structure of the table.  It is also possible to create
5281    composite types with <command>CREATE TYPE AS</command>.
5282   </para>
5283
5284   <table>
5285    <title><structname>pg_type</> Columns</title>
5286
5287    <tgroup cols="4">
5288     <thead>
5289      <row>
5290       <entry>Name</entry>
5291       <entry>Type</entry>
5292       <entry>References</entry>
5293       <entry>Description</entry>
5294      </row>
5295     </thead>
5296
5297     <tbody>
5298      <row>
5299       <entry><structfield>typname</structfield></entry>
5300       <entry><type>name</type></entry>
5301       <entry></entry>
5302       <entry>Data type name</entry>
5303      </row>
5304
5305      <row>
5306       <entry><structfield>typnamespace</structfield></entry>
5307       <entry><type>oid</type></entry>
5308       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
5309       <entry>
5310        The OID of the namespace that contains this type
5311       </entry>
5312      </row>
5313
5314      <row>
5315       <entry><structfield>typowner</structfield></entry>
5316       <entry><type>oid</type></entry>
5317       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
5318       <entry>Owner of the type</entry>
5319      </row>
5320
5321      <row>
5322       <entry><structfield>typlen</structfield></entry>
5323       <entry><type>int2</type></entry>
5324       <entry></entry>
5325       <entry>
5326        For a fixed-size type, <structfield>typlen</structfield> is the number
5327        of bytes in the internal representation of the type.  But for a
5328        variable-length type, <structfield>typlen</structfield> is negative.
5329        -1 indicates a <quote>varlena</> type (one that has a length word),
5330        -2 indicates a null-terminated C string.
5331       </entry>
5332      </row>
5333
5334      <row>
5335       <entry><structfield>typbyval</structfield></entry>
5336       <entry><type>bool</type></entry>
5337       <entry></entry>
5338       <entry>
5339        <structfield>typbyval</structfield> determines whether internal
5340        routines pass a value of this type by value or by reference.
5341        <structfield>typbyval</structfield> had better be false if
5342        <structfield>typlen</structfield> is not 1, 2, or 4 (or 8 on machines
5343        where Datum is 8 bytes).
5344        Variable-length types are always passed by reference. Note that
5345        <structfield>typbyval</structfield> can be false even if the
5346        length would allow pass-by-value.
5347       </entry>
5348      </row>
5349
5350      <row>
5351       <entry><structfield>typtype</structfield></entry>
5352       <entry><type>char</type></entry>
5353       <entry></entry>
5354       <entry>
5355        <structfield>typtype</structfield> is
5356        <literal>b</literal> for a base type,
5357        <literal>c</literal> for a composite type (e.g., a table's row type),
5358        <literal>d</literal> for a domain,
5359        <literal>e</literal> for an enum type,
5360        or <literal>p</literal> for a pseudo-type.
5361        See also <structfield>typrelid</structfield> and
5362        <structfield>typbasetype</structfield>.
5363       </entry>
5364      </row>
5365
5366      <row>
5367       <entry><structfield>typcategory</structfield></entry>
5368       <entry><type>char</type></entry>
5369       <entry></entry>
5370       <entry>
5371        <structfield>typcategory</structfield> is an arbitrary classification
5372        of data types that is used by the parser to determine which implicit
5373        casts should be <quote>preferred</>.
5374        See <xref linkend="catalog-typcategory-table">.
5375       </entry>
5376      </row>
5377
5378      <row>
5379       <entry><structfield>typispreferred</structfield></entry>
5380       <entry><type>bool</type></entry>
5381       <entry></entry>
5382       <entry>
5383        True if the type is a preferred cast target within its
5384        <structfield>typcategory</structfield>
5385       </entry>
5386      </row>
5387
5388      <row>
5389       <entry><structfield>typisdefined</structfield></entry>
5390       <entry><type>bool</type></entry>
5391       <entry></entry>
5392       <entry>
5393        True if the type is defined, false if this is a placeholder
5394        entry for a not-yet-defined type.  When
5395        <structfield>typisdefined</structfield> is false, nothing
5396        except the type name, namespace, and OID can be relied on.
5397       </entry>
5398      </row>
5399
5400      <row>
5401       <entry><structfield>typdelim</structfield></entry>
5402       <entry><type>char</type></entry>
5403       <entry></entry>
5404       <entry>
5405        Character that separates two values of this type when parsing
5406        array input.  Note that the delimiter is associated with the array
5407        element data type, not the array data type.
5408       </entry>
5409      </row>
5410
5411      <row>
5412       <entry><structfield>typrelid</structfield></entry>
5413       <entry><type>oid</type></entry>
5414       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
5415       <entry>
5416        If this is a composite type (see
5417        <structfield>typtype</structfield>), then this column points to
5418        the <structname>pg_class</structname> entry that defines the
5419        corresponding table.  (For a free-standing composite type, the
5420        <structname>pg_class</structname> entry doesn't really represent
5421        a table, but it is needed anyway for the type's
5422        <structname>pg_attribute</structname> entries to link to.)
5423        Zero for non-composite types.
5424       </entry>
5425      </row>
5426
5427      <row>
5428       <entry><structfield>typelem</structfield></entry>
5429       <entry><type>oid</type></entry>
5430       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
5431       <entry>
5432        If <structfield>typelem</structfield> is not 0 then it
5433        identifies another row in <structname>pg_type</structname>.
5434        The current type can then be subscripted like an array yielding
5435        values of type <structfield>typelem</structfield>.  A
5436        <quote>true</quote> array type is variable length
5437        (<structfield>typlen</structfield> = -1),
5438        but some fixed-length (<structfield>typlen</structfield> &gt; 0) types
5439        also have nonzero <structfield>typelem</structfield>, for example
5440        <type>name</type> and <type>point</type>.
5441        If a fixed-length type has a <structfield>typelem</structfield> then
5442        its internal representation must be some number of values of the
5443        <structfield>typelem</structfield> data type with no other data.
5444        Variable-length array types have a header defined by the array
5445        subroutines.
5446       </entry>
5447      </row>
5448
5449      <row>
5450       <entry><structfield>typarray</structfield></entry>
5451       <entry><type>oid</type></entry>
5452       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
5453       <entry>
5454        If <structfield>typarray</structfield> is not 0 then it
5455        identifies another row in <structname>pg_type</structname>, which
5456        is the <quote>true</quote> array type having this type as element
5457       </entry>
5458      </row>
5459
5460      <row>
5461       <entry><structfield>typinput</structfield></entry>
5462       <entry><type>regproc</type></entry>
5463       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5464       <entry>Input conversion function (text format)</entry>
5465      </row>
5466
5467      <row>
5468       <entry><structfield>typoutput</structfield></entry>
5469       <entry><type>regproc</type></entry>
5470       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5471       <entry>Output conversion function (text format)</entry>
5472      </row>
5473
5474      <row>
5475       <entry><structfield>typreceive</structfield></entry>
5476       <entry><type>regproc</type></entry>
5477       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5478       <entry>Input conversion function (binary format), or 0 if none</entry>
5479      </row>
5480
5481      <row>
5482       <entry><structfield>typsend</structfield></entry>
5483       <entry><type>regproc</type></entry>
5484       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5485       <entry>Output conversion function (binary format), or 0 if none</entry>
5486      </row>
5487
5488      <row>
5489       <entry><structfield>typmodin</structfield></entry>
5490       <entry><type>regproc</type></entry>
5491       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5492       <entry>Type modifier input function, or 0 if type does not support modifiers</entry>
5493      </row>
5494
5495      <row>
5496       <entry><structfield>typmodout</structfield></entry>
5497       <entry><type>regproc</type></entry>
5498       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5499       <entry>Type modifier output function, or 0 to use the standard format</entry>
5500      </row>
5501
5502      <row>
5503       <entry><structfield>typanalyze</structfield></entry>
5504       <entry><type>regproc</type></entry>
5505       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5506       <entry>Custom <command>ANALYZE</command> function, or 0 to use the standard function</entry>
5507      </row>
5508
5509      <row>
5510       <entry><structfield>typalign</structfield></entry>
5511       <entry><type>char</type></entry>
5512       <entry></entry>
5513       <entry><para>
5514
5515        <structfield>typalign</structfield> is the alignment required
5516        when storing a value of this type.  It applies to storage on
5517        disk as well as most representations of the value inside
5518        <productname>PostgreSQL</>.
5519        When multiple values are stored consecutively, such
5520        as in the representation of a complete row on disk, padding is
5521        inserted before a datum of this type so that it begins on the
5522        specified boundary.  The alignment reference is the beginning
5523        of the first datum in the sequence.
5524       </para>
5525
5526       <para>
5527        Possible values are:
5528        <itemizedlist>
5529         <listitem>
5530          <para><literal>c</> = <type>char</type> alignment, i.e., no alignment needed.</para>
5531         </listitem>
5532         <listitem>
5533          <para><literal>s</> = <type>short</type> alignment (2 bytes on most machines).</para>
5534         </listitem>
5535         <listitem>
5536          <para><literal>i</> = <type>int</type> alignment (4 bytes on most machines).</para>
5537         </listitem>
5538         <listitem>
5539          <para><literal>d</> = <type>double</type> alignment (8 bytes on many machines, but by no means all).</para>
5540         </listitem>
5541        </itemizedlist>
5542       </para><note>
5543        <para>
5544         For types used in system tables, it is critical that the size
5545         and alignment defined in <structname>pg_type</structname>
5546         agree with the way that the compiler will lay out the column in
5547         a structure representing a table row.
5548        </para>
5549       </note></entry>
5550      </row>
5551
5552      <row>
5553       <entry><structfield>typstorage</structfield></entry>
5554       <entry><type>char</type></entry>
5555       <entry></entry>
5556       <entry><para>
5557        <structfield>typstorage</structfield> tells for varlena
5558        types (those with <structfield>typlen</structfield> = -1) if
5559        the type is prepared for toasting and what the default strategy
5560        for attributes of this type should be.
5561        Possible values are
5562        <itemizedlist>
5563         <listitem>
5564          <para><literal>p</>: Value must always be stored plain.</para>
5565         </listitem>
5566         <listitem>
5567          <para>
5568           <literal>e</>: Value can be stored in a <quote>secondary</quote>
5569           relation (if relation has one, see
5570           <literal>pg_class.reltoastrelid</literal>).
5571          </para>
5572         </listitem>
5573         <listitem>
5574          <para><literal>m</>: Value can be stored compressed inline.</para>
5575         </listitem>
5576         <listitem>
5577          <para><literal>x</>: Value can be stored compressed inline or stored in <quote>secondary</quote> storage.</para>
5578         </listitem>
5579        </itemizedlist>
5580        Note that <literal>m</> columns can also be moved out to secondary
5581        storage, but only as a last resort (<literal>e</> and <literal>x</> columns are
5582        moved first).
5583       </para></entry>
5584      </row>
5585
5586      <row>
5587       <entry><structfield>typnotnull</structfield></entry>
5588       <entry><type>bool</type></entry>
5589       <entry></entry>
5590       <entry><para>
5591        <structfield>typnotnull</structfield> represents a not-null
5592        constraint on a type.  Used for domains only.
5593       </para></entry>
5594      </row>
5595
5596      <row>
5597       <entry><structfield>typbasetype</structfield></entry>
5598       <entry><type>oid</type></entry>
5599       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
5600       <entry><para>
5601        If this is a domain (see <structfield>typtype</structfield>), then
5602        <structfield>typbasetype</structfield> identifies the type that this
5603        one is based on.  Zero if this type is not a domain.
5604       </para></entry>
5605      </row>
5606
5607      <row>
5608       <entry><structfield>typtypmod</structfield></entry>
5609       <entry><type>int4</type></entry>
5610       <entry></entry>
5611       <entry><para>
5612        Domains use <structfield>typtypmod</structfield> to record the <literal>typmod</>
5613        to be applied to their base type (-1 if base type does not use a
5614        <literal>typmod</>).  -1 if this type is not a domain.
5615       </para></entry>
5616      </row>
5617
5618      <row>
5619       <entry><structfield>typndims</structfield></entry>
5620       <entry><type>int4</type></entry>
5621       <entry></entry>
5622       <entry><para>
5623        <structfield>typndims</structfield> is the number of array dimensions
5624        for a domain that is an array (that is, <structfield>typbasetype</> is
5625        an array type; the domain's <structfield>typelem</> will match the base
5626        type's <structfield>typelem</structfield>).
5627        Zero for types other than domains over array types.
5628        </para></entry>
5629      </row>
5630
5631      <row>
5632       <entry><structfield>typdefaultbin</structfield></entry>
5633       <entry><type>text</type></entry>
5634       <entry></entry>
5635       <entry><para>
5636        If <structfield>typdefaultbin</> is not null, it is the <function>nodeToString()</function>
5637        representation of a default expression for the type.  This is
5638        only used for domains.
5639       </para></entry>
5640      </row>
5641
5642      <row>
5643       <entry><structfield>typdefault</structfield></entry>
5644       <entry><type>text</type></entry>
5645       <entry></entry>
5646       <entry><para>
5647        <structfield>typdefault</> is null if the type has no associated
5648        default value. If <structfield>typdefaultbin</> is not null,
5649        <structfield>typdefault</> must contain a human-readable version of the
5650        default expression represented by <structfield>typdefaultbin</>.  If
5651        <structfield>typdefaultbin</> is null and <structfield>typdefault</> is
5652        not, then <structfield>typdefault</> is the external representation of
5653        the type's default value, which might be fed to the type's input
5654        converter to produce a constant.
5655       </para></entry>
5656      </row>
5657     </tbody>
5658    </tgroup>
5659   </table>
5660
5661   <para>
5662    <xref linkend="catalog-typcategory-table"> lists the system-defined values
5663    of <structfield>typcategory</>.  Any future additions to this list will
5664    also be upper-case ASCII letters.  All other ASCII characters are reserved
5665    for user-defined categories.
5666   </para>
5667
5668   <table id="catalog-typcategory-table">
5669    <title><structfield>typcategory</> Codes</title>
5670
5671    <tgroup cols="2">
5672     <thead>
5673      <row>
5674       <entry>Code</entry>
5675       <entry>Category</entry>
5676      </row>
5677     </thead>
5678
5679     <tbody>
5680      <row>
5681       <entry><literal>A</literal></entry>
5682       <entry>Array types</entry>
5683      </row>
5684      <row>
5685       <entry><literal>B</literal></entry>
5686       <entry>Boolean types</entry>
5687      </row>
5688      <row>
5689       <entry><literal>C</literal></entry>
5690       <entry>Composite types</entry>
5691      </row>
5692      <row>
5693       <entry><literal>D</literal></entry>
5694       <entry>Date/time types</entry>
5695      </row>
5696      <row>
5697       <entry><literal>E</literal></entry>
5698       <entry>Enum types</entry>
5699      </row>
5700      <row>
5701       <entry><literal>G</literal></entry>
5702       <entry>Geometric types</entry>
5703      </row>
5704      <row>
5705       <entry><literal>I</literal></entry>
5706       <entry>Network address types</entry>
5707      </row>
5708      <row>
5709       <entry><literal>N</literal></entry>
5710       <entry>Numeric types</entry>
5711      </row>
5712      <row>
5713       <entry><literal>P</literal></entry>
5714       <entry>Pseudo-types</entry>
5715      </row>
5716      <row>
5717       <entry><literal>S</literal></entry>
5718       <entry>String types</entry>
5719      </row>
5720      <row>
5721       <entry><literal>T</literal></entry>
5722       <entry>Timespan types</entry>
5723      </row>
5724      <row>
5725       <entry><literal>U</literal></entry>
5726       <entry>User-defined types</entry>
5727      </row>
5728      <row>
5729       <entry><literal>V</literal></entry>
5730       <entry>Bit-string types</entry>
5731      </row>
5732      <row>
5733       <entry><literal>X</literal></entry>
5734       <entry><type>unknown</> type</entry>
5735      </row>
5736     </tbody>
5737    </tgroup>
5738   </table>
5739
5740  </sect1>
5741
5742
5743  <sect1 id="catalog-pg-user-mapping">
5744   <title><structname>pg_user_mapping</structname></title>
5745
5746   <indexterm zone="catalog-pg-user-mapping">
5747    <primary>pg_user_mapping</primary>
5748   </indexterm>
5749
5750   <para>
5751    The catalog <structname>pg_user_mapping</structname> stores
5752    the mappings from local user to remote.  Access to this catalog is
5753    restricted from normal users, use the view
5754    <link linkend="view-pg-user-mappings"><structname>pg_user_mappings</structname></link>
5755    instead.
5756   </para>
5757
5758   <table>
5759    <title><structname>pg_user_mapping</> Columns</title>
5760
5761    <tgroup cols="4">
5762     <thead>
5763      <row>
5764       <entry>Name</entry>
5765       <entry>Type</entry>
5766       <entry>References</entry>
5767       <entry>Description</entry>
5768      </row>
5769     </thead>
5770
5771     <tbody>
5772      <row>
5773       <entry><structfield>umuser</structfield></entry>
5774       <entry><type>oid</type></entry>
5775       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
5776       <entry>OID of the local role being mapped, 0 if the user mapping is public</entry>
5777      </row>
5778
5779      <row>
5780       <entry><structfield>umserver</structfield></entry>
5781       <entry><type>oid</type></entry>
5782       <entry><literal><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link>.oid</literal></entry>
5783       <entry>
5784        The OID of the foreign server that contains this mapping
5785       </entry>
5786      </row>
5787
5788      <row>
5789       <entry><structfield>umoptions</structfield></entry>
5790       <entry><type>text[]</type></entry>
5791       <entry></entry>
5792       <entry>
5793        User mapping specific options, as <quote>keyword=value</> strings
5794       </entry>
5795      </row>
5796     </tbody>
5797    </tgroup>
5798   </table>
5799  </sect1>
5800
5801
5802  <sect1 id="views-overview">
5803   <title>System Views</title>
5804
5805   <para>
5806    In addition to the system catalogs, <productname>PostgreSQL</productname>
5807    provides a number of built-in views.  Some system views provide convenient
5808    access to some commonly used queries on the system catalogs.  Other views
5809    provide access to internal server state.
5810   </para>
5811
5812   <para>
5813    The information schema (<xref linkend="information-schema">) provides
5814    an alternative set of views which overlap the functionality of the system
5815    views.  Since the information schema is SQL-standard whereas the views
5816    described here are <productname>PostgreSQL</productname>-specific,
5817    it's usually better to use the information schema if it provides all
5818    the information you need.
5819   </para>
5820
5821   <para>
5822    <xref linkend="view-table"> lists the system views described here.
5823    More detailed documentation of each view follows below.
5824    There are some additional views that provide access to the results of
5825    the statistics collector; they are described in <xref
5826    linkend="monitoring-stats-views-table">.
5827   </para>
5828
5829   <para>
5830    Except where noted, all the views described here are read-only.
5831   </para>
5832
5833   <table id="view-table">
5834    <title>System Views</title>
5835
5836    <tgroup cols="2">
5837     <thead>
5838      <row>
5839       <entry>View Name</entry>
5840       <entry>Purpose</entry>
5841      </row>
5842     </thead>
5843
5844     <tbody>
5845      <row>
5846       <entry><link linkend="view-pg-cursors"><structname>pg_cursors</structname></link></entry>
5847       <entry>open cursors</entry>
5848      </row>
5849
5850      <row>
5851       <entry><link linkend="view-pg-group"><structname>pg_group</structname></link></entry>
5852       <entry>groups of database users</entry>
5853      </row>
5854
5855      <row>
5856       <entry><link linkend="view-pg-indexes"><structname>pg_indexes</structname></link></entry>
5857       <entry>indexes</entry>
5858      </row>
5859
5860      <row>
5861       <entry><link linkend="view-pg-locks"><structname>pg_locks</structname></link></entry>
5862       <entry>currently held locks</entry>
5863      </row>
5864
5865      <row>
5866       <entry><link linkend="view-pg-prepared-statements"><structname>pg_prepared_statements</structname></link></entry>
5867       <entry>prepared statements</entry>
5868      </row>
5869
5870      <row>
5871       <entry><link linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link></entry>
5872       <entry>prepared transactions</entry>
5873      </row>
5874
5875      <row>
5876       <entry><link linkend="view-pg-roles"><structname>pg_roles</structname></link></entry>
5877       <entry>database roles</entry>
5878      </row>
5879
5880      <row>
5881       <entry><link linkend="view-pg-rules"><structname>pg_rules</structname></link></entry>
5882       <entry>rules</entry>
5883      </row>
5884
5885      <row>
5886       <entry><link linkend="view-pg-settings"><structname>pg_settings</structname></link></entry>
5887       <entry>parameter settings</entry>
5888      </row>
5889
5890      <row>
5891       <entry><link linkend="view-pg-shadow"><structname>pg_shadow</structname></link></entry>
5892       <entry>database users</entry>
5893      </row>
5894
5895      <row>
5896       <entry><link linkend="view-pg-stats"><structname>pg_stats</structname></link></entry>
5897       <entry>planner statistics</entry>
5898      </row>
5899
5900      <row>
5901       <entry><link linkend="view-pg-tables"><structname>pg_tables</structname></link></entry>
5902       <entry>tables</entry>
5903      </row>
5904
5905      <row>
5906       <entry><link linkend="view-pg-timezone-abbrevs"><structname>pg_timezone_abbrevs</structname></link></entry>
5907       <entry>time zone abbreviations</entry>
5908      </row>
5909
5910      <row>
5911       <entry><link linkend="view-pg-timezone-names"><structname>pg_timezone_names</structname></link></entry>
5912       <entry>time zone names</entry>
5913      </row>
5914
5915      <row>
5916       <entry><link linkend="view-pg-user"><structname>pg_user</structname></link></entry>
5917       <entry>database users</entry>
5918      </row>
5919
5920      <row>
5921       <entry><link linkend="view-pg-views"><structname>pg_views</structname></link></entry>
5922       <entry>views</entry>
5923      </row>
5924
5925     </tbody>
5926    </tgroup>
5927   </table>
5928  </sect1>
5929
5930  <sect1 id="view-pg-cursors">
5931   <title><structname>pg_cursors</structname></title>
5932
5933   <indexterm zone="view-pg-cursors">
5934    <primary>pg_cursors</primary>
5935   </indexterm>
5936
5937   <para>
5938    The <structname>pg_cursors</structname> view lists the cursors that
5939    are currently available. Cursors can be defined in several ways:
5940    <itemizedlist>
5941     <listitem>
5942      <para>
5943       via the <xref linkend="sql-declare">
5944       statement in SQL
5945      </para>
5946     </listitem>
5947
5948     <listitem>
5949      <para>
5950       via the Bind message in the frontend/backend protocol, as
5951       described in <xref linkend="protocol-flow-ext-query">
5952      </para>
5953     </listitem>
5954
5955     <listitem>
5956      <para>
5957       via the Server Programming Interface (SPI), as described in
5958       <xref linkend="spi-interface">
5959      </para>
5960     </listitem>
5961    </itemizedlist>
5962
5963    The <structname>pg_cursors</structname> view displays cursors
5964    created by any of these means. Cursors only exist for the duration
5965    of the transaction that defines them, unless they have been
5966    declared <literal>WITH HOLD</literal>. Therefore non-holdable
5967    cursors are only present in the view until the end of their
5968    creating transaction.
5969
5970    <note>
5971     <para>
5972      Cursors are used internally to implement some of the components
5973      of <productname>PostgreSQL</>, such as procedural languages.
5974      Therefore, the <structname>pg_cursors</> view might include cursors
5975      that have not been explicitly created by the user.
5976     </para>
5977    </note>
5978   </para>
5979
5980   <table>
5981    <title><structname>pg_cursors</> Columns</title>
5982
5983    <tgroup cols="3">
5984     <thead>
5985      <row>
5986       <entry>Name</entry>
5987       <entry>Type</entry>
5988       <entry>Description</entry>
5989      </row>
5990     </thead>
5991
5992     <tbody>
5993      <row>
5994       <entry><structfield>name</structfield></entry>
5995       <entry><type>text</type></entry>
5996       <entry>The name of the cursor</entry>
5997      </row>
5998
5999      <row>
6000       <entry><structfield>statement</structfield></entry>
6001       <entry><type>text</type></entry>
6002       <entry>The verbatim query string submitted to declare this cursor</entry>
6003      </row>
6004
6005      <row>
6006       <entry><structfield>is_holdable</structfield></entry>
6007       <entry><type>boolean</type></entry>
6008       <entry>
6009        <literal>true</literal> if the cursor is holdable (that is, it
6010        can be accessed after the transaction that declared the cursor
6011        has committed); <literal>false</literal> otherwise
6012        </entry>
6013      </row>
6014
6015      <row>
6016       <entry><structfield>is_binary</structfield></entry>
6017       <entry><type>boolean</type></entry>
6018       <entry>
6019        <literal>true</literal> if the cursor was declared
6020        <literal>BINARY</literal>; <literal>false</literal>
6021        otherwise
6022        </entry>
6023      </row>
6024
6025      <row>
6026       <entry><structfield>is_scrollable</structfield></entry>
6027       <entry><type>boolean</type></entry>
6028       <entry>
6029        <literal>true</> if the cursor is scrollable (that is, it
6030        allows rows to be retrieved in a nonsequential manner);
6031        <literal>false</literal> otherwise
6032        </entry>
6033      </row>
6034
6035      <row>
6036       <entry><structfield>creation_time</structfield></entry>
6037       <entry><type>timestamptz</type></entry>
6038       <entry>The time at which the cursor was declared</entry>
6039      </row>
6040     </tbody>
6041    </tgroup>
6042   </table>
6043
6044   <para>
6045    The <structname>pg_cursors</structname> view is read only.
6046   </para>
6047
6048  </sect1>
6049
6050  <sect1 id="view-pg-group">
6051   <title><structname>pg_group</structname></title>
6052
6053   <indexterm zone="view-pg-group">
6054    <primary>pg_group</primary>
6055   </indexterm>
6056
6057   <para>
6058    The view <structname>pg_group</structname> exists for backwards
6059    compatibility: it emulates a catalog that existed in
6060    <productname>PostgreSQL</productname> before version 8.1.
6061    It shows the names and members of all roles that are marked as not
6062    <structfield>rolcanlogin</>, which is an approximation to the set
6063    of roles that are being used as groups.
6064   </para>
6065
6066   <table>
6067    <title><structname>pg_group</> Columns</title>
6068
6069    <tgroup cols="4">
6070     <thead>
6071      <row>
6072       <entry>Name</entry>
6073       <entry>Type</entry>
6074       <entry>References</entry>
6075       <entry>Description</entry>
6076      </row>
6077     </thead>
6078
6079     <tbody>
6080      <row>
6081       <entry><structfield>groname</structfield></entry>
6082       <entry><type>name</type></entry>
6083       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6084       <entry>Name of the group</entry>
6085      </row>
6086
6087      <row>
6088       <entry><structfield>grosysid</structfield></entry>
6089       <entry><type>oid</type></entry>
6090       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6091       <entry>ID of this group</entry>
6092      </row>
6093
6094      <row>
6095       <entry><structfield>grolist</structfield></entry>
6096       <entry><type>oid[]</type></entry>
6097       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6098       <entry>An array containing the IDs of the roles in this group</entry>
6099      </row>
6100     </tbody>
6101    </tgroup>
6102   </table>
6103
6104  </sect1>
6105
6106  <sect1 id="view-pg-indexes">
6107   <title><structname>pg_indexes</structname></title>
6108
6109   <indexterm zone="view-pg-indexes">
6110    <primary>pg_indexes</primary>
6111   </indexterm>
6112
6113   <para>
6114    The view <structname>pg_indexes</structname> provides access to
6115    useful information about each index in the database.
6116   </para>
6117
6118   <table>
6119    <title><structname>pg_indexes</> Columns</title>
6120
6121    <tgroup cols="4">
6122     <thead>
6123      <row>
6124       <entry>Name</entry>
6125       <entry>Type</entry>
6126       <entry>References</entry>
6127       <entry>Description</entry>
6128      </row>
6129     </thead>
6130     <tbody>
6131      <row>
6132       <entry><structfield>schemaname</structfield></entry>
6133       <entry><type>name</type></entry>
6134       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
6135       <entry>Name of schema containing table and index</entry>
6136      </row>
6137      <row>
6138       <entry><structfield>tablename</structfield></entry>
6139       <entry><type>name</type></entry>
6140       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6141       <entry>Name of table the index is for</entry>
6142      </row>
6143      <row>
6144       <entry><structfield>indexname</structfield></entry>
6145       <entry><type>name</type></entry>
6146       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6147       <entry>Name of index</entry>
6148      </row>
6149      <row>
6150       <entry><structfield>tablespace</structfield></entry>
6151       <entry><type>name</type></entry>
6152       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.spcname</literal></entry>
6153       <entry>Name of tablespace containing index (null if default for database)</entry>
6154      </row>
6155      <row>
6156       <entry><structfield>indexdef</structfield></entry>
6157       <entry><type>text</type></entry>
6158       <entry></entry>
6159       <entry>Index definition (a reconstructed <command>CREATE INDEX</command>
6160       command)</entry>
6161      </row>
6162     </tbody>
6163    </tgroup>
6164   </table>
6165
6166  </sect1>
6167
6168  <sect1 id="view-pg-locks">
6169   <title><structname>pg_locks</structname></title>
6170
6171   <indexterm zone="view-pg-locks">
6172    <primary>pg_locks</primary>
6173   </indexterm>
6174
6175   <para>
6176    The view <structname>pg_locks</structname> provides access to
6177    information about the locks held by open transactions within the
6178    database server.  See <xref linkend="mvcc"> for more discussion
6179    of locking.
6180   </para>
6181
6182   <para>
6183    <structname>pg_locks</structname> contains one row per active lockable
6184    object, requested lock mode, and relevant transaction.  Thus, the same
6185    lockable object might
6186    appear many times, if multiple transactions are holding or waiting
6187    for locks on it.  However, an object that currently has no locks on it
6188    will not appear at all.
6189   </para>
6190
6191   <para>
6192    There are several distinct types of lockable objects:
6193    whole relations (e.g., tables), individual pages of relations,
6194    individual tuples of relations,
6195    transaction IDs (both virtual and permanent IDs),
6196    and general database objects (identified by class OID and object OID,
6197    in the same way as in <structname>pg_description</structname> or
6198    <structname>pg_depend</structname>).  Also, the right to extend a
6199    relation is represented as a separate lockable object.
6200   </para>
6201
6202   <table>
6203    <title><structname>pg_locks</> Columns</title>
6204
6205    <tgroup cols="4">
6206     <thead>
6207      <row>
6208       <entry>Name</entry>
6209       <entry>Type</entry>
6210       <entry>References</entry>
6211       <entry>Description</entry>
6212      </row>
6213     </thead>
6214     <tbody>
6215      <row>
6216       <entry><structfield>locktype</structfield></entry>
6217       <entry><type>text</type></entry>
6218       <entry></entry>
6219       <entry>
6220        Type of the lockable object:
6221        <literal>relation</>,
6222        <literal>extend</>,
6223        <literal>page</>,
6224        <literal>tuple</>,
6225        <literal>transactionid</>,
6226        <literal>virtualxid</>,
6227        <literal>object</>,
6228        <literal>userlock</>, or
6229        <literal>advisory</>
6230       </entry>
6231      </row>
6232      <row>
6233       <entry><structfield>database</structfield></entry>
6234       <entry><type>oid</type></entry>
6235       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
6236       <entry>
6237        OID of the database in which the object exists, or
6238        zero if the object is a shared object, or
6239        null if the object is a transaction ID
6240       </entry>
6241      </row>
6242      <row>
6243       <entry><structfield>relation</structfield></entry>
6244       <entry><type>oid</type></entry>
6245       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
6246       <entry>
6247        OID of the relation, or null if the object is not
6248        a relation or part of a relation
6249       </entry>
6250      </row>
6251      <row>
6252       <entry><structfield>page</structfield></entry>
6253       <entry><type>integer</type></entry>
6254       <entry></entry>
6255       <entry>
6256        Page number within the relation, or null if the object
6257        is not a tuple or relation page
6258       </entry>
6259      </row>
6260      <row>
6261       <entry><structfield>tuple</structfield></entry>
6262       <entry><type>smallint</type></entry>
6263       <entry></entry>
6264       <entry>
6265        Tuple number within the page, or null if the object is not a tuple
6266       </entry>
6267      </row>
6268      <row>
6269       <entry><structfield>virtualxid</structfield></entry>
6270       <entry><type>text</type></entry>
6271       <entry></entry>
6272       <entry>
6273        Virtual ID of a transaction, or null if the object is not a
6274        virtual transaction ID
6275       </entry>
6276      </row>
6277      <row>
6278       <entry><structfield>transactionid</structfield></entry>
6279       <entry><type>xid</type></entry>
6280       <entry></entry>
6281       <entry>
6282        ID of a transaction, or null if the object is not a transaction ID
6283       </entry>
6284      </row>
6285      <row>
6286       <entry><structfield>classid</structfield></entry>
6287       <entry><type>oid</type></entry>
6288       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
6289       <entry>
6290        OID of the system catalog containing the object, or null if the
6291        object is not a general database object
6292       </entry>
6293      </row>
6294      <row>
6295       <entry><structfield>objid</structfield></entry>
6296       <entry><type>oid</type></entry>
6297       <entry>any OID column</entry>
6298       <entry>
6299        OID of the object within its system catalog, or null if the
6300        object is not a general database object.
6301        For advisory locks it is used to distinguish the two key
6302        spaces (<literal>1</> for an int8 key, <literal>2</> for two
6303        int4 keys).
6304       </entry>
6305      </row>
6306      <row>
6307       <entry><structfield>objsubid</structfield></entry>
6308       <entry><type>smallint</type></entry>
6309       <entry></entry>
6310       <entry>
6311        For a table column, this is the column number (the
6312        <structfield>classid</> and <structfield>objid</> refer to the
6313        table itself).  For all other object types, this column is
6314        zero.  Null if the object is not a general database object
6315       </entry>
6316      </row>
6317      <row>
6318       <entry><structfield>virtualtransaction</structfield></entry>
6319       <entry><type>text</type></entry>
6320       <entry></entry>
6321       <entry>
6322        Virtual ID of the transaction that is holding or awaiting this lock
6323       </entry>
6324      </row>
6325      <row>
6326       <entry><structfield>pid</structfield></entry>
6327       <entry><type>integer</type></entry>
6328       <entry></entry>
6329       <entry>
6330        Process ID of the server process holding or awaiting this
6331        lock.  Null if the lock is held by a prepared transaction.
6332       </entry>
6333      </row>
6334      <row>
6335       <entry><structfield>mode</structfield></entry>
6336       <entry><type>text</type></entry>
6337       <entry></entry>
6338       <entry>Name of the lock mode held or desired by this process (see <xref
6339       linkend="locking-tables">)</entry>
6340      </row>
6341      <row>
6342       <entry><structfield>granted</structfield></entry>
6343       <entry><type>boolean</type></entry>
6344       <entry></entry>
6345       <entry>True if lock is held, false if lock is awaited</entry>
6346      </row>
6347     </tbody>
6348    </tgroup>
6349   </table>
6350
6351   <para>
6352    <structfield>granted</structfield> is true in a row representing a lock
6353    held by the indicated transaction.  False indicates that this transaction is
6354    currently waiting to acquire this lock, which implies that some other
6355    transaction is holding a conflicting lock mode on the same lockable object.
6356    The waiting transaction will sleep until the other lock is released (or a
6357    deadlock situation is detected). A single transaction can be waiting to
6358    acquire at most one lock at a time.
6359   </para>
6360
6361   <para>
6362    Every transaction holds an exclusive lock on its virtual transaction ID for
6363    its entire duration.  If a permanent ID is assigned to the transaction
6364    (which normally happens only if the transaction changes the state of the
6365    database), it also holds an exclusive lock on its permanent transaction ID
6366    until it ends.  When one transaction finds it necessary to wait specifically
6367    for another transaction, it does so by attempting to acquire share lock on
6368    the other transaction ID (either virtual or permanent ID depending on the
6369    situation). That will succeed only when the other transaction
6370    terminates and releases its locks.
6371   </para>
6372
6373   <para>
6374    Although tuples are a lockable type of object,
6375    information about row-level locks is stored on disk, not in memory,
6376    and therefore row-level locks normally do not appear in this view.
6377    If a transaction is waiting for a
6378    row-level lock, it will usually appear in the view as waiting for the
6379    permanent transaction ID of the current holder of that row lock.
6380   </para>
6381
6382   <para>
6383    Advisory locks can be acquired on keys consisting of either a single
6384    <type>bigint</type> value or two integer values.  A <type>bigint</type> key is displayed with its
6385    high-order half in the <structfield>classid</> column, its low-order half
6386    in the <structfield>objid</> column, and <structfield>objsubid</> equal
6387    to 1.  Integer keys are displayed with the first key in the
6388    <structfield>classid</> column, the second key in the <structfield>objid</>
6389    column, and <structfield>objsubid</> equal to 2.  The actual meaning of
6390    the keys is up to the user.  Advisory locks are local to each database,
6391    so the <structfield>database</> column is meaningful for an advisory lock.
6392   </para>
6393
6394   <para>
6395    When the <structname>pg_locks</structname> view is accessed, the
6396    internal lock manager data structures are momentarily locked, and
6397    a copy is made for the view to display.  This ensures that the
6398    view produces a consistent set of results, while not blocking
6399    normal lock manager operations longer than necessary.  Nonetheless
6400    there could be some impact on database performance if this view is
6401    frequently accessed.
6402   </para>
6403
6404   <para>
6405    <structname>pg_locks</structname> provides a global view of all locks
6406    in the database cluster, not only those relevant to the current database.
6407    Although its <structfield>relation</structfield> column can be joined
6408    against <structname>pg_class</>.<structfield>oid</> to identify locked
6409    relations, this will only work correctly for relations in the current
6410    database (those for which the <structfield>database</structfield> column
6411    is either the current database's OID or zero).
6412   </para>
6413
6414   <para>
6415    The <structfield>pid</structfield> column can be joined to the
6416    <structfield>procpid</structfield> column of the
6417    <structname>pg_stat_activity</structname> view to get more
6418    information on the session holding or waiting to hold each lock.
6419    Also, if you are using prepared transactions, the
6420    <structfield>transaction</> column can be joined to the
6421    <structfield>transaction</structfield> column of the
6422    <structname>pg_prepared_xacts</structname> view to get more
6423    information on prepared transactions that hold locks.
6424    (A prepared transaction can never be waiting for a lock,
6425    but it continues to hold the locks it acquired while running.)
6426   </para>
6427
6428  </sect1>
6429
6430  <sect1 id="view-pg-prepared-statements">
6431   <title><structname>pg_prepared_statements</structname></title>
6432
6433   <indexterm zone="view-pg-prepared-statements">
6434    <primary>pg_prepared_statements</primary>
6435   </indexterm>
6436
6437   <para>
6438    The <structname>pg_prepared_statements</structname> view displays
6439    all the prepared statements that are available in the current
6440    session. See <xref linkend="sql-prepare"> for more information about prepared
6441    statements.
6442   </para>
6443
6444   <para>
6445    <structname>pg_prepared_statements</structname> contains one row
6446    for each prepared statement. Rows are added to the view when a new
6447    prepared statement is created and removed when a prepared statement
6448    is released (for example, via the <xref linkend="sql-deallocate"> command).
6449   </para>
6450
6451   <table>
6452    <title><structname>pg_prepared_statements</> Columns</title>
6453
6454    <tgroup cols="3">
6455     <thead>
6456      <row>
6457       <entry>Name</entry>
6458       <entry>Type</entry>
6459       <entry>Description</entry>
6460      </row>
6461     </thead>
6462     <tbody>
6463      <row>
6464       <entry><structfield>name</structfield></entry>
6465       <entry><type>text</type></entry>
6466       <entry>
6467        The identifier of the prepared statement
6468       </entry>
6469      </row>
6470      <row>
6471       <entry><structfield>statement</structfield></entry>
6472       <entry><type>text</type></entry>
6473       <entry>
6474        The query string submitted by the client to create this
6475        prepared statement. For prepared statements created via SQL,
6476        this is the <command>PREPARE</command> statement submitted by
6477        the client. For prepared statements created via the
6478        frontend/backend protocol, this is the text of the prepared
6479        statement itself.
6480       </entry>
6481      </row>
6482      <row>
6483       <entry><structfield>prepare_time</structfield></entry>
6484       <entry><type>timestamptz</type></entry>
6485       <entry>
6486        The time at which the prepared statement was created
6487       </entry>
6488      </row>
6489      <row>
6490       <entry><structfield>parameter_types</structfield></entry>
6491       <entry><type>regtype[]</type></entry>
6492       <entry>
6493        The expected parameter types for the prepared statement in the
6494        form of an array of <type>regtype</type>. The OID corresponding
6495        to an element of this array can be obtained by casting the
6496        <type>regtype</type> value to <type>oid</type>.
6497       </entry>
6498      </row>
6499      <row>
6500       <entry><structfield>from_sql</structfield></entry>
6501       <entry><type>boolean</type></entry>
6502       <entry>
6503        <literal>true</literal> if the prepared statement was created
6504        via the <command>PREPARE</command> SQL statement;
6505        <literal>false</literal> if the statement was prepared via the
6506        frontend/backend protocol
6507       </entry>
6508      </row>
6509     </tbody>
6510    </tgroup>
6511   </table>
6512
6513   <para>
6514    The <structname>pg_prepared_statements</structname> view is read only.
6515   </para>
6516  </sect1>
6517
6518  <sect1 id="view-pg-prepared-xacts">
6519   <title><structname>pg_prepared_xacts</structname></title>
6520
6521   <indexterm zone="view-pg-prepared-xacts">
6522    <primary>pg_prepared_xacts</primary>
6523   </indexterm>
6524
6525   <para>
6526    The view <structname>pg_prepared_xacts</structname> displays
6527    information about transactions that are currently prepared for two-phase
6528    commit (see <xref linkend="sql-prepare-transaction"> for details).
6529   </para>
6530
6531   <para>
6532    <structname>pg_prepared_xacts</structname> contains one row per prepared
6533    transaction.  An entry is removed when the transaction is committed or
6534    rolled back.
6535   </para>
6536
6537   <table>
6538    <title><structname>pg_prepared_xacts</> Columns</title>
6539
6540    <tgroup cols="4">
6541     <thead>
6542      <row>
6543       <entry>Name</entry>
6544       <entry>Type</entry>
6545       <entry>References</entry>
6546       <entry>Description</entry>
6547      </row>
6548     </thead>
6549     <tbody>
6550      <row>
6551       <entry><structfield>transaction</structfield></entry>
6552       <entry><type>xid</type></entry>
6553       <entry></entry>
6554       <entry>
6555        Numeric transaction identifier of the prepared transaction
6556       </entry>
6557      </row>
6558      <row>
6559       <entry><structfield>gid</structfield></entry>
6560       <entry><type>text</type></entry>
6561       <entry></entry>
6562       <entry>
6563        Global transaction identifier that was assigned to the transaction
6564       </entry>
6565      </row>
6566      <row>
6567       <entry><structfield>prepared</structfield></entry>
6568       <entry><type>timestamp with time zone</type></entry>
6569       <entry></entry>
6570       <entry>
6571        Time at which the transaction was prepared for commit
6572       </entry>
6573      </row>
6574      <row>
6575       <entry><structfield>owner</structfield></entry>
6576       <entry><type>name</type></entry>
6577       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6578       <entry>
6579        Name of the user that executed the transaction
6580       </entry>
6581      </row>
6582      <row>
6583       <entry><structfield>database</structfield></entry>
6584       <entry><type>name</type></entry>
6585       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.datname</literal></entry>
6586       <entry>
6587        Name of the database in which the transaction was executed
6588       </entry>
6589      </row>
6590     </tbody>
6591    </tgroup>
6592   </table>
6593
6594   <para>
6595    When the <structname>pg_prepared_xacts</structname> view is accessed, the
6596    internal transaction manager data structures are momentarily locked, and
6597    a copy is made for the view to display.  This ensures that the
6598    view produces a consistent set of results, while not blocking
6599    normal operations longer than necessary.  Nonetheless
6600    there could be some impact on database performance if this view is
6601    frequently accessed.
6602   </para>
6603
6604  </sect1>
6605
6606  <sect1 id="view-pg-roles">
6607   <title><structname>pg_roles</structname></title>
6608
6609   <indexterm zone="view-pg-roles">
6610    <primary>pg_roles</primary>
6611   </indexterm>
6612
6613   <para>
6614    The view <structname>pg_roles</structname> provides access to
6615    information about database roles.  This is simply a publicly
6616    readable view of
6617    <link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>
6618    that blanks out the password field.
6619   </para>
6620
6621   <para>
6622    This view explicitly exposes the OID column of the underlying table,
6623    since that is needed to do joins to other catalogs.
6624   </para>
6625
6626   <table>
6627    <title><structname>pg_roles</> Columns</title>
6628
6629    <tgroup cols="4">
6630     <thead>
6631      <row>
6632       <entry>Name</entry>
6633       <entry>Type</entry>
6634       <entry>References</entry>
6635       <entry>Description</entry>
6636      </row>
6637     </thead>
6638
6639     <tbody>
6640      <row>
6641       <entry><structfield>rolname</structfield></entry>
6642       <entry><type>name</type></entry>
6643       <entry></entry>
6644       <entry>Role name</entry>
6645      </row>
6646
6647      <row>
6648       <entry><structfield>rolsuper</structfield></entry>
6649       <entry><type>bool</type></entry>
6650       <entry></entry>
6651       <entry>Role has superuser privileges</entry>
6652      </row>
6653
6654      <row>
6655       <entry><structfield>rolinherit</structfield></entry>
6656       <entry><type>bool</type></entry>
6657       <entry></entry>
6658       <entry>Role automatically inherits privileges of roles it is a
6659        member of</entry>
6660      </row>
6661
6662      <row>
6663       <entry><structfield>rolcreaterole</structfield></entry>
6664       <entry><type>bool</type></entry>
6665       <entry></entry>
6666       <entry>Role can create more roles</entry>
6667      </row>
6668
6669      <row>
6670       <entry><structfield>rolcreatedb</structfield></entry>
6671       <entry><type>bool</type></entry>
6672       <entry></entry>
6673       <entry>Role can create databases</entry>
6674      </row>
6675
6676      <row>
6677       <entry><structfield>rolcatupdate</structfield></entry>
6678       <entry><type>bool</type></entry>
6679       <entry></entry>
6680       <entry>
6681        Role can update system catalogs directly.  (Even a superuser cannot do
6682        this unless this column is true.)
6683       </entry>
6684      </row>
6685
6686      <row>
6687       <entry><structfield>rolcanlogin</structfield></entry>
6688       <entry><type>bool</type></entry>
6689       <entry></entry>
6690       <entry>
6691        Role can log in. That is, this role can be given as the initial
6692        session authorization identifier
6693       </entry>
6694      </row>
6695
6696      <row>
6697       <entry><structfield>rolconnlimit</structfield></entry>
6698       <entry><type>int4</type></entry>
6699       <entry></entry>
6700       <entry>
6701        For roles that can log in, this sets maximum number of concurrent
6702        connections this role can make.  -1 means no limit.
6703       </entry>
6704      </row>
6705
6706      <row>
6707       <entry><structfield>rolpassword</structfield></entry>
6708       <entry><type>text</type></entry>
6709       <entry></entry>
6710       <entry>Not the password (always reads as <literal>********</>)</entry>
6711      </row>
6712
6713      <row>
6714       <entry><structfield>rolvaliduntil</structfield></entry>
6715       <entry><type>timestamptz</type></entry>
6716       <entry></entry>
6717       <entry>Password expiry time (only used for password authentication);
6718        null if no expiration</entry>
6719      </row>
6720
6721      <row>
6722       <entry><structfield>oid</structfield></entry>
6723       <entry><type>oid</type></entry>
6724       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6725       <entry>ID of role</entry>
6726      </row>
6727     </tbody>
6728    </tgroup>
6729   </table>
6730
6731  </sect1>
6732
6733  <sect1 id="view-pg-rules">
6734   <title><structname>pg_rules</structname></title>
6735
6736   <indexterm zone="view-pg-rules">
6737    <primary>pg_rules</primary>
6738   </indexterm>
6739
6740   <para>
6741    The view <structname>pg_rules</structname> provides access to
6742    useful information about query rewrite rules.
6743   </para>
6744
6745   <table>
6746    <title><structname>pg_rules</> Columns</title>
6747
6748    <tgroup cols="4">
6749     <thead>
6750      <row>
6751       <entry>Name</entry>
6752       <entry>Type</entry>
6753       <entry>References</entry>
6754       <entry>Description</entry>
6755      </row>
6756     </thead>
6757     <tbody>
6758      <row>
6759       <entry><structfield>schemaname</structfield></entry>
6760       <entry><type>name</type></entry>
6761       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
6762       <entry>Name of schema containing table</entry>
6763      </row>
6764      <row>
6765       <entry><structfield>tablename</structfield></entry>
6766       <entry><type>name</type></entry>
6767       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6768       <entry>Name of table the rule is for</entry>
6769      </row>
6770      <row>
6771       <entry><structfield>rulename</structfield></entry>
6772       <entry><type>name</type></entry>
6773       <entry><literal><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link>.rulename</literal></entry>
6774       <entry>Name of rule</entry>
6775      </row>
6776      <row>
6777       <entry><structfield>definition</structfield></entry>
6778       <entry><type>text</type></entry>
6779       <entry></entry>
6780       <entry>Rule definition (a reconstructed creation command)</entry>
6781      </row>
6782     </tbody>
6783    </tgroup>
6784   </table>
6785
6786   <para>
6787    The <structname>pg_rules</> view excludes the <literal>ON SELECT</> rules
6788    of views; those can be seen in <structname>pg_views</>.
6789   </para>
6790
6791  </sect1>
6792
6793  <sect1 id="view-pg-settings">
6794   <title><structname>pg_settings</structname></title>
6795
6796   <indexterm zone="view-pg-settings">
6797    <primary>pg_settings</primary>
6798   </indexterm>
6799
6800   <para>
6801    The view <structname>pg_settings</structname> provides access to
6802    run-time parameters of the server.  It is essentially an alternative
6803    interface to the <xref linkend="sql-show">
6804    and <xref linkend="sql-set"> commands.
6805    It also provides access to some facts about each parameter that are
6806    not directly available from <command>SHOW</>, such as minimum and
6807    maximum values.
6808   </para>
6809
6810   <table>
6811    <title><structname>pg_settings</> Columns</title>
6812
6813    <tgroup cols="3">
6814     <thead>
6815      <row>
6816       <entry>Name</entry>
6817       <entry>Type</entry>
6818       <entry>Description</entry>
6819      </row>
6820     </thead>
6821     <tbody>
6822      <row>
6823       <entry><structfield>name</structfield></entry>
6824       <entry><type>text</type></entry>
6825       <entry>Run-time configuration parameter name</entry>
6826      </row>
6827      <row>
6828       <entry><structfield>setting</structfield></entry>
6829       <entry><type>text</type></entry>
6830       <entry>Current value of the parameter</entry>
6831      </row>
6832      <row>
6833       <entry><structfield>unit</structfield></entry>
6834       <entry><type>text</type></entry>
6835       <entry>Implicit unit of the parameter</entry>
6836      </row>
6837      <row>
6838       <entry><structfield>category</structfield></entry>
6839       <entry><type>text</type></entry>
6840       <entry>Logical group of the parameter</entry>
6841      </row>
6842      <row>
6843       <entry><structfield>short_desc</structfield></entry>
6844       <entry><type>text</type></entry>
6845       <entry>A brief description of the parameter</entry>
6846      </row>
6847      <row>
6848       <entry><structfield>extra_desc</structfield></entry>
6849       <entry><type>text</type></entry>
6850       <entry>Additional, more detailed, description of the parameter</entry>
6851      </row>
6852      <row>
6853       <entry><structfield>context</structfield></entry>
6854       <entry><type>text</type></entry>
6855       <entry>Context required to set the parameter's value</entry>
6856      </row>
6857      <row>
6858       <entry><structfield>vartype</structfield></entry>
6859       <entry><type>text</type></entry>
6860       <entry>Parameter type (<literal>bool</>, <literal>enum</>,
6861        <literal>integer</>, <literal>real</>, or <literal>string</>)
6862       </entry>
6863      </row>
6864      <row>
6865       <entry><structfield>source</structfield></entry>
6866       <entry><type>text</type></entry>
6867       <entry>Source of the current parameter value</entry>
6868      </row>
6869      <row>
6870       <entry><structfield>min_val</structfield></entry>
6871       <entry><type>text</type></entry>
6872       <entry>Minimum allowed value of the parameter (null for non-numeric
6873       values)</entry>
6874      </row>
6875      <row>
6876       <entry><structfield>max_val</structfield></entry>
6877       <entry><type>text</type></entry>
6878       <entry>Maximum allowed value of the parameter (null for non-numeric
6879       values)</entry>
6880      </row>
6881      <row>
6882       <entry><structfield>enumvals</structfield></entry>
6883       <entry><type>text[]</type></entry>
6884       <entry>Allowed values of an enum parameter (null for non-enum
6885       values)</entry>
6886      </row>
6887      <row>
6888       <entry><structfield>boot_val</structfield></entry>
6889       <entry><type>text</type></entry>
6890       <entry>Parameter value assumed at server startup if the parameter is
6891       not otherwise set</entry>
6892      </row>
6893      <row>
6894       <entry><structfield>reset_val</structfield></entry>
6895       <entry><type>text</type></entry>
6896       <entry>Value that <command>RESET</command> would reset the parameter to
6897       in the current session</entry>
6898      </row>
6899      <row>
6900       <entry><structfield>sourcefile</structfield></entry>
6901       <entry><type>text</type></entry>
6902       <entry>Configuration file the current value was set in (null for
6903       values set from sources other than configuration files, or when
6904       examined by a non-superuser);
6905       helpful when using <literal>include</> directives in configuration files</entry>
6906      </row>
6907      <row>
6908       <entry><structfield>sourceline</structfield></entry>
6909       <entry><type>integer</type></entry>
6910       <entry>Line number within the configuration file the current value was
6911       set at (null for values set from sources other than configuration files,
6912       or when examined by a non-superuser)
6913       </entry>
6914      </row>
6915     </tbody>
6916    </tgroup>
6917   </table>
6918
6919   <para>
6920    The <structname>pg_settings</structname> view cannot be inserted into or
6921    deleted from, but it can be updated.  An <command>UPDATE</command> applied
6922    to a row of <structname>pg_settings</structname> is equivalent to executing
6923    the <xref linkend="sql-set"> command on that named
6924    parameter. The change only affects the value used by the current
6925    session. If an <command>UPDATE</command> is issued within a transaction
6926    that is later aborted, the effects of the <command>UPDATE</command> command
6927    disappear when the transaction is rolled back. Once the surrounding
6928    transaction is committed, the effects will persist until the end of the
6929    session, unless overridden by another <command>UPDATE</command> or
6930    <command>SET</command>.
6931   </para>
6932
6933  </sect1>
6934
6935  <sect1 id="view-pg-shadow">
6936   <title><structname>pg_shadow</structname></title>
6937
6938   <indexterm zone="view-pg-shadow">
6939    <primary>pg_shadow</primary>
6940   </indexterm>
6941
6942   <para>
6943    The view <structname>pg_shadow</structname> exists for backwards
6944    compatibility: it emulates a catalog that existed in
6945    <productname>PostgreSQL</productname> before version 8.1.
6946    It shows properties of all roles that are marked as
6947    <structfield>rolcanlogin</> in
6948    <link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.
6949   </para>
6950
6951   <para>
6952    The name stems from the fact that this table
6953    should not be readable by the public since it contains passwords.
6954    <link linkend="view-pg-user"><structname>pg_user</structname></link>
6955    is a publicly readable view on
6956    <structname>pg_shadow</structname> that blanks out the password field.
6957   </para>
6958
6959   <table>
6960    <title><structname>pg_shadow</> Columns</title>
6961
6962    <tgroup cols="4">
6963     <thead>
6964      <row>
6965       <entry>Name</entry>
6966       <entry>Type</entry>
6967       <entry>References</entry>
6968       <entry>Description</entry>
6969      </row>
6970     </thead>
6971
6972     <tbody>
6973      <row>
6974       <entry><structfield>usename</structfield></entry>
6975       <entry><type>name</type></entry>
6976       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6977       <entry>User name</entry>
6978      </row>
6979
6980      <row>
6981       <entry><structfield>usesysid</structfield></entry>
6982       <entry><type>oid</type></entry>
6983       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6984       <entry>ID of this user</entry>
6985      </row>
6986
6987      <row>
6988       <entry><structfield>usecreatedb</structfield></entry>
6989       <entry><type>bool</type></entry>
6990       <entry></entry>
6991       <entry>User can create databases</entry>
6992      </row>
6993
6994      <row>
6995       <entry><structfield>usesuper</structfield></entry>
6996       <entry><type>bool</type></entry>
6997       <entry></entry>
6998       <entry>User is a superuser</entry>
6999      </row>
7000
7001      <row>
7002       <entry><structfield>usecatupd</structfield></entry>
7003       <entry><type>bool</type></entry>
7004       <entry></entry>
7005       <entry>
7006        User can update system catalogs.  (Even a superuser cannot do
7007        this unless this column is true.)
7008       </entry>
7009      </row>
7010
7011      <row>
7012       <entry><structfield>passwd</structfield></entry>
7013       <entry><type>text</type></entry>
7014       <entry></entry>
7015       <entry>Password (possibly encrypted); null if none.  See
7016       <link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>
7017       for details of how encrypted passwords are stored.</entry>
7018      </row>
7019
7020      <row>
7021       <entry><structfield>valuntil</structfield></entry>
7022       <entry><type>abstime</type></entry>
7023       <entry></entry>
7024       <entry>Password expiry time (only used for password authentication)</entry>
7025      </row>
7026
7027      <row>
7028       <entry><structfield>useconfig</structfield></entry>
7029       <entry><type>text[]</type></entry>
7030       <entry></entry>
7031       <entry>Session defaults for run-time configuration variables</entry>
7032      </row>
7033     </tbody>
7034    </tgroup>
7035   </table>
7036
7037  </sect1>
7038
7039  <sect1 id="view-pg-stats">
7040   <title><structname>pg_stats</structname></title>
7041
7042   <indexterm zone="view-pg-stats">
7043    <primary>pg_stats</primary>
7044   </indexterm>
7045
7046   <para>
7047    The view <structname>pg_stats</structname> provides access to
7048    the information stored in the <link
7049    linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link>
7050    catalog.  This view allows access only to rows of
7051    <structname>pg_statistic</structname> that correspond to tables the
7052    user has permission to read, and therefore it is safe to allow public
7053    read access to this view.
7054   </para>
7055
7056   <para>
7057    <structname>pg_stats</structname> is also designed to present the
7058    information in a more readable format than the underlying catalog
7059    &mdash; at the cost that its schema must be extended whenever new slot types
7060    are defined for <structname>pg_statistic</structname>.
7061   </para>
7062
7063   <table>
7064    <title><structname>pg_stats</> Columns</title>
7065
7066    <tgroup cols="4">
7067     <thead>
7068      <row>
7069       <entry>Name</entry>
7070       <entry>Type</entry>
7071       <entry>References</entry>
7072       <entry>Description</entry>
7073      </row>
7074     </thead>
7075     <tbody>
7076      <row>
7077       <entry><structfield>schemaname</structfield></entry>
7078       <entry><type>name</type></entry>
7079       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
7080       <entry>Name of schema containing table</entry>
7081      </row>
7082
7083      <row>
7084       <entry><structfield>tablename</structfield></entry>
7085       <entry><type>name</type></entry>
7086       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
7087       <entry>Name of table</entry>
7088      </row>
7089
7090      <row>
7091       <entry><structfield>attname</structfield></entry>
7092       <entry><type>name</type></entry>
7093       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attname</literal></entry>
7094       <entry>Name of the column described by this row</entry>
7095      </row>
7096
7097      <row>
7098       <entry><structfield>inherited</structfield></entry>
7099       <entry><type>bool</type></entry>
7100       <entry></entry>
7101       <entry>If true, this row includes inheritance child columns, not just the
7102        values in the specified table</entry>
7103      </row>
7104
7105      <row>
7106       <entry><structfield>null_frac</structfield></entry>
7107       <entry><type>real</type></entry>
7108       <entry></entry>
7109       <entry>Fraction of column entries that are null</entry>
7110      </row>
7111
7112      <row>
7113       <entry><structfield>avg_width</structfield></entry>
7114       <entry><type>integer</type></entry>
7115       <entry></entry>
7116       <entry>Average width in bytes of column's entries</entry>
7117      </row>
7118
7119      <row>
7120       <entry><structfield>n_distinct</structfield></entry>
7121       <entry><type>real</type></entry>
7122       <entry></entry>
7123       <entry>
7124        If greater than zero, the estimated number of distinct values in the
7125        column.  If less than zero, the negative of the number of distinct
7126        values divided by the number of rows.  (The negated form is used when
7127        <command>ANALYZE</> believes that the number of distinct values is
7128        likely to increase as the table grows; the positive form is used when
7129        the column seems to have a fixed number of possible values.)  For
7130        example, -1 indicates a unique column in which the number of distinct
7131        values is the same as the number of rows.
7132       </entry>
7133      </row>
7134
7135      <row>
7136       <entry><structfield>most_common_vals</structfield></entry>
7137       <entry><type>anyarray</type></entry>
7138       <entry></entry>
7139       <entry>
7140        A list of the most common values in the column. (Null if
7141        no values seem to be more common than any others.)
7142        For some data types such as <type>tsvector</>, this is a list of
7143        the most common element values rather than values of the type itself.
7144       </entry>
7145      </row>
7146
7147      <row>
7148       <entry><structfield>most_common_freqs</structfield></entry>
7149       <entry><type>real[]</type></entry>
7150       <entry></entry>
7151       <entry>
7152        A list of the frequencies of the most common values or elements,
7153        i.e., number of occurrences of each divided by total number of rows.
7154        (Null when <structfield>most_common_vals</structfield> is.)
7155        For some data types such as <type>tsvector</>, it can also store some
7156        additional information, making it longer than the
7157        <structfield>most_common_vals</> array.
7158       </entry>
7159      </row>
7160
7161      <row>
7162       <entry><structfield>histogram_bounds</structfield></entry>
7163       <entry><type>anyarray</type></entry>
7164       <entry></entry>
7165       <entry>
7166        A list of values that divide the column's values into groups of
7167        approximately equal population.  The values in
7168        <structfield>most_common_vals</>, if present, are omitted from this
7169        histogram calculation.  (This column is null if the column data type
7170        does not have a <literal>&lt;</> operator or if the
7171        <structfield>most_common_vals</> list accounts for the entire
7172        population.)
7173       </entry>
7174      </row>
7175
7176      <row>
7177       <entry><structfield>correlation</structfield></entry>
7178       <entry><type>real</type></entry>
7179       <entry></entry>
7180       <entry>
7181        Statistical correlation between physical row ordering and
7182        logical ordering of the column values.  This ranges from -1 to +1.
7183        When the value is near -1 or +1, an index scan on the column will
7184        be estimated to be cheaper than when it is near zero, due to reduction
7185        of random access to the disk.  (This column is null if the column data
7186        type does not have a <literal>&lt;</> operator.)
7187       </entry>
7188      </row>
7189     </tbody>
7190    </tgroup>
7191   </table>
7192
7193   <para>
7194    The maximum number of entries in the <structfield>most_common_vals</>
7195    and <structfield>histogram_bounds</> arrays can be set on a
7196    column-by-column basis using the <command>ALTER TABLE SET STATISTICS</>
7197    command, or globally by setting the
7198    <xref linkend="guc-default-statistics-target"> run-time parameter.
7199   </para>
7200
7201  </sect1>
7202
7203  <sect1 id="view-pg-tables">
7204   <title><structname>pg_tables</structname></title>
7205
7206   <indexterm zone="view-pg-tables">
7207    <primary>pg_tables</primary>
7208   </indexterm>
7209
7210   <para>
7211    The view <structname>pg_tables</structname> provides access to
7212    useful information about each table in the database.
7213   </para>
7214
7215   <table>
7216    <title><structname>pg_tables</> Columns</title>
7217
7218    <tgroup cols="4">
7219     <thead>
7220      <row>
7221       <entry>Name</entry>
7222       <entry>Type</entry>
7223       <entry>References</entry>
7224       <entry>Description</entry>
7225      </row>
7226     </thead>
7227     <tbody>
7228      <row>
7229       <entry><structfield>schemaname</structfield></entry>
7230       <entry><type>name</type></entry>
7231       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
7232       <entry>Name of schema containing table</entry>
7233      </row>
7234      <row>
7235       <entry><structfield>tablename</structfield></entry>
7236       <entry><type>name</type></entry>
7237       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
7238       <entry>Name of table</entry>
7239      </row>
7240      <row>
7241       <entry><structfield>tableowner</structfield></entry>
7242       <entry><type>name</type></entry>
7243       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
7244       <entry>Name of table's owner</entry>
7245      </row>
7246      <row>
7247       <entry><structfield>tablespace</structfield></entry>
7248       <entry><type>name</type></entry>
7249       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.spcname</literal></entry>
7250       <entry>Name of tablespace containing table (null if default for database)</entry>
7251      </row>
7252      <row>
7253       <entry><structfield>hasindexes</structfield></entry>
7254       <entry><type>boolean</type></entry>
7255       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhasindex</literal></entry>
7256       <entry>True if table has (or recently had) any indexes</entry>
7257      </row>
7258      <row>
7259       <entry><structfield>hasrules</structfield></entry>
7260       <entry><type>boolean</type></entry>
7261       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhasrules</literal></entry>
7262       <entry>True if table has (or once had) rules</entry>
7263      </row>
7264      <row>
7265       <entry><structfield>hastriggers</structfield></entry>
7266       <entry><type>boolean</type></entry>
7267       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhastriggers</literal></entry>
7268       <entry>True if table has (or once had) triggers</entry>
7269      </row>
7270     </tbody>
7271    </tgroup>
7272   </table>
7273
7274  </sect1>
7275
7276  <sect1 id="view-pg-timezone-abbrevs">
7277   <title><structname>pg_timezone_abbrevs</structname></title>
7278
7279   <indexterm zone="view-pg-timezone-abbrevs">
7280    <primary>pg_timezone_abbrevs</primary>
7281   </indexterm>
7282
7283   <para>
7284    The view <structname>pg_timezone_abbrevs</structname> provides a list
7285    of time zone abbreviations that are currently recognized by the datetime
7286    input routines.  The contents of this view change when the
7287    <xref linkend="guc-timezone-abbreviations"> run-time parameter is modified.
7288   </para>
7289
7290   <table>
7291    <title><structname>pg_timezone_abbrevs</> Columns</title>
7292
7293    <tgroup cols="3">
7294     <thead>
7295      <row>
7296       <entry>Name</entry>
7297       <entry>Type</entry>
7298       <entry>Description</entry>
7299      </row>
7300     </thead>
7301     <tbody>
7302      <row>
7303       <entry><structfield>abbrev</structfield></entry>
7304       <entry><type>text</type></entry>
7305       <entry>Time zone abbreviation</entry>
7306      </row>
7307      <row>
7308       <entry><structfield>utc_offset</structfield></entry>
7309       <entry><type>interval</type></entry>
7310       <entry>Offset from UTC (positive means east of Greenwich)</entry>
7311      </row>
7312      <row>
7313       <entry><structfield>is_dst</structfield></entry>
7314       <entry><type>boolean</type></entry>
7315       <entry>True if this is a daylight-savings abbreviation</entry>
7316      </row>
7317     </tbody>
7318    </tgroup>
7319   </table>
7320
7321  </sect1>
7322
7323  <sect1 id="view-pg-timezone-names">
7324   <title><structname>pg_timezone_names</structname></title>
7325
7326   <indexterm zone="view-pg-timezone-names">
7327    <primary>pg_timezone_names</primary>
7328   </indexterm>
7329
7330   <para>
7331    The view <structname>pg_timezone_names</structname> provides a list
7332    of time zone names that are recognized by <command>SET TIMEZONE</>,
7333    along with their associated abbreviations, UTC offsets,
7334    and daylight-savings status.
7335    Unlike the abbreviations shown in <link
7336    linkend="view-pg-timezone-abbrevs"><structname>pg_timezone_abbrevs</structname></link>, many of these names imply a set of daylight-savings transition
7337    date rules.  Therefore, the associated information changes across local DST
7338    boundaries.  The displayed information is computed based on the current
7339    value of <function>CURRENT_TIMESTAMP</>.
7340   </para>
7341
7342   <table>
7343    <title><structname>pg_timezone_names</> Columns</title>
7344
7345    <tgroup cols="3">
7346     <thead>
7347      <row>
7348       <entry>Name</entry>
7349       <entry>Type</entry>
7350       <entry>Description</entry>
7351      </row>
7352     </thead>
7353     <tbody>
7354      <row>
7355       <entry><structfield>name</structfield></entry>
7356       <entry><type>text</type></entry>
7357       <entry>Time zone name</entry>
7358      </row>
7359      <row>
7360       <entry><structfield>abbrev</structfield></entry>
7361       <entry><type>text</type></entry>
7362       <entry>Time zone abbreviation</entry>
7363      </row>
7364      <row>
7365       <entry><structfield>utc_offset</structfield></entry>
7366       <entry><type>interval</type></entry>
7367       <entry>Offset from UTC (positive means east of Greenwich)</entry>
7368      </row>
7369      <row>
7370       <entry><structfield>is_dst</structfield></entry>
7371       <entry><type>boolean</type></entry>
7372       <entry>True if currently observing daylight savings</entry>
7373      </row>
7374     </tbody>
7375    </tgroup>
7376   </table>
7377
7378  </sect1>
7379
7380  <sect1 id="view-pg-user">
7381   <title><structname>pg_user</structname></title>
7382
7383   <indexterm zone="view-pg-user">
7384    <primary>pg_user</primary>
7385   </indexterm>
7386
7387   <para>
7388    The view <structname>pg_user</structname> provides access to
7389    information about database users.  This is simply a publicly
7390    readable view of
7391    <link linkend="view-pg-shadow"><structname>pg_shadow</structname></link>
7392    that blanks out the password field.
7393   </para>
7394
7395   <table>
7396    <title><structname>pg_user</> Columns</title>
7397
7398    <tgroup cols="3">
7399     <thead>
7400      <row>
7401       <entry>Name</entry>
7402       <entry>Type</entry>
7403       <entry>Description</entry>
7404      </row>
7405     </thead>
7406     <tbody>
7407      <row>
7408       <entry><structfield>usename</structfield></entry>
7409       <entry><type>name</type></entry>
7410       <entry>User name</entry>
7411      </row>
7412
7413      <row>
7414       <entry><structfield>usesysid</structfield></entry>
7415       <entry><type>int4</type></entry>
7416       <entry>User ID (arbitrary number used to reference this user)</entry>
7417      </row>
7418
7419      <row>
7420       <entry><structfield>usecreatedb</structfield></entry>
7421       <entry><type>bool</type></entry>
7422       <entry>User can create databases</entry>
7423      </row>
7424
7425      <row>
7426       <entry><structfield>usesuper</structfield></entry>
7427       <entry><type>bool</type></entry>
7428       <entry>User is a superuser</entry>
7429      </row>
7430
7431      <row>
7432       <entry><structfield>usecatupd</structfield></entry>
7433       <entry><type>bool</type></entry>
7434       <entry>
7435        User can update system catalogs.  (Even a superuser cannot do
7436        this unless this column is true.)
7437       </entry>
7438      </row>
7439
7440      <row>
7441       <entry><structfield>passwd</structfield></entry>
7442       <entry><type>text</type></entry>
7443       <entry>Not the password (always reads as <literal>********</>)</entry>
7444      </row>
7445
7446      <row>
7447       <entry><structfield>valuntil</structfield></entry>
7448       <entry><type>abstime</type></entry>
7449       <entry>Password expiry time (only used for password authentication)</entry>
7450      </row>
7451
7452      <row>
7453       <entry><structfield>useconfig</structfield></entry>
7454       <entry><type>text[]</type></entry>
7455       <entry>Session defaults for run-time configuration variables</entry>
7456      </row>
7457     </tbody>
7458    </tgroup>
7459   </table>
7460
7461  </sect1>
7462
7463  <sect1 id="view-pg-user-mappings">
7464   <title><structname>pg_user_mappings</structname></title>
7465
7466   <indexterm zone="view-pg-user-mappings">
7467    <primary>pg_user_mappings</primary>
7468   </indexterm>
7469
7470   <para>
7471    The view <structname>pg_user_mappings</structname> provides access
7472    to information about user mappings.  This is essentially a publicly
7473    readable view of
7474    <link linkend="catalog-pg-user-mapping"><structname>pg_user_mapping</structname></link>
7475    that leaves out the options field if the user has no rights to use
7476    it.
7477   </para>
7478
7479   <table>
7480    <title><structname>pg_user_mappings</> Columns</title>
7481
7482    <tgroup cols="4">
7483     <thead>
7484      <row>
7485       <entry>Name</entry>
7486       <entry>Type</entry>
7487       <entry>References</entry>
7488       <entry>Description</entry>
7489      </row>
7490     </thead>
7491
7492     <tbody>
7493      <row>
7494       <entry><structfield>umid</structfield></entry>
7495       <entry><type>oid</type></entry>
7496       <entry><literal><link linkend="catalog-pg-user-mapping"><structname>pg_user_mapping</structname></link>.oid</literal></entry>
7497       <entry>OID of the user mapping</entry>
7498      </row>
7499
7500      <row>
7501       <entry><structfield>srvid</structfield></entry>
7502       <entry><type>oid</type></entry>
7503       <entry><literal><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link>.oid</literal></entry>
7504       <entry>
7505        The OID of the foreign server that contains this mapping
7506       </entry>
7507      </row>
7508
7509      <row>
7510       <entry><structfield>srvname</structfield></entry>
7511       <entry><type>text</type></entry>
7512       <entry></entry>
7513       <entry>
7514        Name of the foreign server
7515       </entry>
7516      </row>
7517
7518      <row>
7519       <entry><structfield>umuser</structfield></entry>
7520       <entry><type>oid</type></entry>
7521       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
7522       <entry>OID of the local role being mapped, 0 if the user mapping is public</entry>
7523      </row>
7524
7525      <row>
7526       <entry><structfield>usename</structfield></entry>
7527       <entry><type>name</type></entry>
7528       <entry></entry>
7529       <entry>Name of the local user to be mapped</entry>
7530      </row>
7531
7532      <row>
7533       <entry><structfield>umoptions</structfield></entry>
7534       <entry><type>text[]</type></entry>
7535       <entry></entry>
7536       <entry>
7537        User mapping specific options, as <quote>keyword=value</>
7538        strings, if the current user is the owner of the foreign
7539        server, else null
7540       </entry>
7541      </row>
7542     </tbody>
7543    </tgroup>
7544   </table>
7545  </sect1>
7546
7547
7548  <sect1 id="view-pg-views">
7549   <title><structname>pg_views</structname></title>
7550
7551   <indexterm zone="view-pg-views">
7552    <primary>pg_views</primary>
7553   </indexterm>
7554
7555   <para>
7556    The view <structname>pg_views</structname> provides access to
7557    useful information about each view in the database.
7558   </para>
7559
7560   <table>
7561    <title><structname>pg_views</> Columns</title>
7562
7563    <tgroup cols="4">
7564     <thead>
7565      <row>
7566       <entry>Name</entry>
7567       <entry>Type</entry>
7568       <entry>References</entry>
7569       <entry>Description</entry>
7570      </row>
7571     </thead>
7572     <tbody>
7573      <row>
7574       <entry><structfield>schemaname</structfield></entry>
7575       <entry><type>name</type></entry>
7576       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
7577       <entry>Name of schema containing view</entry>
7578      </row>
7579      <row>
7580       <entry><structfield>viewname</structfield></entry>
7581       <entry><type>name</type></entry>
7582       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
7583       <entry>Name of view</entry>
7584      </row>
7585      <row>
7586       <entry><structfield>viewowner</structfield></entry>
7587       <entry><type>name</type></entry>
7588       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
7589       <entry>Name of view's owner</entry>
7590      </row>
7591      <row>
7592       <entry><structfield>definition</structfield></entry>
7593       <entry><type>text</type></entry>
7594       <entry></entry>
7595       <entry>View definition (a reconstructed <command>SELECT</command> query)</entry>
7596      </row>
7597     </tbody>
7598    </tgroup>
7599   </table>
7600
7601  </sect1>
7602
7603 </chapter>