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