]> granicus.if.org Git - postgresql/blob - doc/src/sgml/catalogs.sgml
Change the PageGetContents() macro to guarantee its result is maxalign'd,
[postgresql] / doc / src / sgml / catalogs.sgml
1 <!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.167 2008/07/11 07:02:43 petere 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 coercible (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>conislocal</structfield></entry>
1912       <entry><type>bool</type></entry>
1913       <entry></entry>
1914       <entry>
1915        This constraint is defined locally in the relation.  Note that a
1916        constraint can be locally defined and inherited simultaneously
1917       </entry>
1918      </row>
1919
1920      <row>
1921       <entry><structfield>coninhcount</structfield></entry>
1922       <entry><type>int4</type></entry>
1923       <entry></entry>
1924       <entry>
1925        The number of direct ancestors this constraint has.  A constraint with
1926        a nonzero number of ancestors cannot be dropped nor renamed
1927       </entry>
1928      </row>
1929
1930      <row>
1931       <entry><structfield>conkey</structfield></entry>
1932       <entry><type>int2[]</type></entry>
1933       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
1934       <entry>If a table constraint, list of columns which the constraint constrains</entry>
1935      </row>
1936
1937      <row>
1938       <entry><structfield>confkey</structfield></entry>
1939       <entry><type>int2[]</type></entry>
1940       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
1941       <entry>If a foreign key, list of the referenced columns</entry>
1942      </row>
1943
1944      <row>
1945       <entry><structfield>conpfeqop</structfield></entry>
1946       <entry><type>oid[]</type></entry>
1947       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1948       <entry>If a foreign key, list of the equality operators for PK = FK comparisons</entry>
1949      </row>
1950
1951      <row>
1952       <entry><structfield>conppeqop</structfield></entry>
1953       <entry><type>oid[]</type></entry>
1954       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1955       <entry>If a foreign key, list of the equality operators for PK = PK comparisons</entry>
1956      </row>
1957
1958      <row>
1959       <entry><structfield>conffeqop</structfield></entry>
1960       <entry><type>oid[]</type></entry>
1961       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
1962       <entry>If a foreign key, list of the equality operators for FK = FK comparisons</entry>
1963      </row>
1964
1965      <row>
1966       <entry><structfield>conbin</structfield></entry>
1967       <entry><type>text</type></entry>
1968       <entry></entry>
1969       <entry>If a check constraint, an internal representation of the expression</entry>
1970      </row>
1971
1972      <row>
1973       <entry><structfield>consrc</structfield></entry>
1974       <entry><type>text</type></entry>
1975       <entry></entry>
1976       <entry>If a check constraint, a human-readable representation of the expression</entry>
1977      </row>
1978     </tbody>
1979    </tgroup>
1980   </table>
1981
1982   <note>
1983    <para>
1984     <structfield>consrc</structfield> is not updated when referenced objects
1985     change; for example, it won't track renaming of columns.  Rather than
1986     relying on this field, it's best to use <function>pg_get_constraintdef()</>
1987     to extract the definition of a check constraint.
1988    </para>
1989   </note>
1990
1991   <note>
1992    <para>
1993     <literal>pg_class.relchecks</literal> needs to agree with the
1994     number of check-constraint entries found in this table for each
1995     relation.
1996    </para>
1997   </note>
1998
1999  </sect1>
2000
2001  <sect1 id="catalog-pg-conversion">
2002   <title><structname>pg_conversion</structname></title>
2003
2004   <indexterm zone="catalog-pg-conversion">
2005    <primary>pg_conversion</primary>
2006   </indexterm>
2007
2008   <para>
2009    The catalog <structname>pg_conversion</structname> describes the
2010    available encoding conversion procedures.  See
2011    <xref linkend="sql-createconversion" endterm="sql-createconversion-title">
2012    for more information.
2013   </para>
2014
2015   <table>
2016    <title><structname>pg_conversion</> Columns</title>
2017
2018    <tgroup cols=4>
2019     <thead>
2020      <row>
2021       <entry>Name</entry>
2022       <entry>Type</entry>
2023       <entry>References</entry>
2024       <entry>Description</entry>
2025      </row>
2026     </thead>
2027
2028     <tbody>
2029      <row>
2030       <entry><structfield>conname</structfield></entry>
2031       <entry><type>name</type></entry>
2032       <entry></entry>
2033       <entry>Conversion name (unique within a namespace)</entry>
2034      </row>
2035
2036      <row>
2037       <entry><structfield>connamespace</structfield></entry>
2038       <entry><type>oid</type></entry>
2039       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
2040       <entry>
2041        The OID of the namespace that contains this conversion
2042       </entry>
2043      </row>
2044
2045      <row>
2046       <entry><structfield>conowner</structfield></entry>
2047       <entry><type>oid</type></entry>
2048       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2049       <entry>Owner of the conversion</entry>
2050      </row>
2051
2052      <row>
2053       <entry><structfield>conforencoding</structfield></entry>
2054       <entry><type>int4</type></entry>
2055       <entry></entry>
2056       <entry>Source encoding ID</entry>
2057      </row>
2058
2059      <row>
2060       <entry><structfield>contoencoding</structfield></entry>
2061       <entry><type>int4</type></entry>
2062       <entry></entry>
2063       <entry>Destination encoding ID</entry>
2064      </row>
2065
2066      <row>
2067       <entry><structfield>conproc</structfield></entry>
2068       <entry><type>regproc</type></entry>
2069       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2070       <entry>Conversion procedure</entry>
2071      </row>
2072
2073      <row>
2074       <entry><structfield>condefault</structfield></entry>
2075       <entry><type>bool</type></entry>
2076       <entry></entry>
2077       <entry>True if this is the default conversion</entry>
2078      </row>
2079
2080     </tbody>
2081    </tgroup>
2082   </table>
2083
2084  </sect1>
2085
2086  <sect1 id="catalog-pg-database">
2087   <title><structname>pg_database</structname></title>
2088
2089   <indexterm zone="catalog-pg-database">
2090    <primary>pg_database</primary>
2091   </indexterm>
2092
2093   <para>
2094    The catalog <structname>pg_database</structname> stores information about
2095    the available databases.  Databases are created with the <xref
2096    linkend="sql-createdatabase" endterm="sql-createdatabase-title"> command.
2097    Consult <xref linkend="managing-databases"> for details about the meaning
2098    of some of the parameters.
2099   </para>
2100
2101   <para>
2102    Unlike most system catalogs, <structname>pg_database</structname>
2103    is shared across all databases of a cluster: there is only one
2104    copy of <structname>pg_database</structname> per cluster, not
2105    one per database.
2106   </para>
2107
2108   <table>
2109    <title><structname>pg_database</> Columns</title>
2110
2111    <tgroup cols=4>
2112     <thead>
2113      <row>
2114       <entry>Name</entry>
2115       <entry>Type</entry>
2116       <entry>References</entry>
2117       <entry>Description</entry>
2118      </row>
2119     </thead>
2120
2121     <tbody>
2122      <row>
2123       <entry><structfield>datname</structfield></entry>
2124       <entry><type>name</type></entry>
2125       <entry></entry>
2126       <entry>Database name</entry>
2127      </row>
2128
2129      <row>
2130       <entry><structfield>datdba</structfield></entry>
2131       <entry><type>oid</type></entry>
2132       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2133       <entry>Owner of the database, usually the user who created it</entry>
2134      </row>
2135
2136      <row>
2137       <entry><structfield>encoding</structfield></entry>
2138       <entry><type>int4</type></entry>
2139       <entry></entry>
2140       <entry>Character encoding for this database
2141           (<function>pg_encoding_to_char()</function> can translate
2142            this number to the encoding name)</entry>
2143      </row>
2144
2145      <row>
2146       <entry><structfield>datistemplate</structfield></entry>
2147       <entry><type>bool</type></entry>
2148       <entry></entry>
2149       <entry>
2150        If true then this database can be used in the
2151        <literal>TEMPLATE</literal> clause of <command>CREATE
2152        DATABASE</command> to create a new database as a clone of
2153        this one
2154       </entry>
2155      </row>
2156
2157      <row>
2158       <entry><structfield>datallowconn</structfield></entry>
2159       <entry><type>bool</type></entry>
2160       <entry></entry>
2161       <entry>
2162        If false then no one can connect to this database.  This is
2163        used to protect the <literal>template0</> database from being altered
2164       </entry>
2165      </row>
2166
2167      <row>
2168       <entry><structfield>datconnlimit</structfield></entry>
2169       <entry><type>int4</type></entry>
2170       <entry></entry>
2171       <entry>
2172        Sets maximum number of concurrent connections that can be made 
2173        to this database.  -1 means no limit
2174       </entry>
2175      </row>
2176
2177      <row>
2178       <entry><structfield>datlastsysoid</structfield></entry>
2179       <entry><type>oid</type></entry>
2180       <entry></entry>
2181       <entry>
2182        Last system OID in the database; useful
2183        particularly to <application>pg_dump</application>
2184       </entry>
2185      </row>
2186
2187      <row>
2188       <entry><structfield>datfrozenxid</structfield></entry>
2189       <entry><type>xid</type></entry>
2190       <entry></entry>
2191       <entry>
2192        All transaction IDs before this one have been replaced with a permanent
2193        (<quote>frozen</>) transaction ID in this database.  This is used to
2194        track whether the database needs to be vacuumed in order to prevent
2195        transaction ID wraparound or to allow <literal>pg_clog</> to be shrunk.
2196        It is the minimum of the per-table
2197        <structname>pg_class</>.<structfield>relfrozenxid</> values
2198       </entry>
2199      </row>
2200
2201      <row>
2202       <entry><structfield>dattablespace</structfield></entry>
2203       <entry><type>oid</type></entry>
2204       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
2205       <entry>
2206        The default tablespace for the database.
2207        Within this database, all tables for which
2208        <structname>pg_class</>.<structfield>reltablespace</> is zero
2209        will be stored in this tablespace; in particular, all the non-shared
2210        system catalogs will be there
2211       </entry>
2212      </row>
2213
2214      <row>
2215       <entry><structfield>datconfig</structfield></entry>
2216       <entry><type>text[]</type></entry>
2217       <entry></entry>
2218       <entry>Session defaults for run-time configuration variables</entry>
2219      </row>
2220
2221      <row>
2222       <entry><structfield>datacl</structfield></entry>
2223       <entry><type>aclitem[]</type></entry>
2224       <entry></entry>
2225       <entry>
2226        Access privileges; see
2227        <xref linkend="sql-grant" endterm="sql-grant-title"> and
2228        <xref linkend="sql-revoke" endterm="sql-revoke-title">
2229        for details
2230       </entry>
2231      </row>
2232     </tbody>
2233    </tgroup>
2234   </table>
2235  </sect1>
2236
2237
2238  <sect1 id="catalog-pg-depend">
2239   <title><structname>pg_depend</structname></title>
2240
2241   <indexterm zone="catalog-pg-depend">
2242    <primary>pg_depend</primary>
2243   </indexterm>
2244
2245   <para>
2246    The catalog <structname>pg_depend</structname> records the dependency
2247    relationships between database objects.  This information allows
2248    <command>DROP</> commands to find which other objects must be dropped
2249    by <command>DROP CASCADE</> or prevent dropping in the <command>DROP
2250    RESTRICT</> case.
2251   </para>
2252
2253   <para>
2254    See also <link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link>,
2255    which performs a similar function for dependencies involving objects
2256    that are shared across a database cluster.
2257   </para>
2258
2259   <table>
2260    <title><structname>pg_depend</> Columns</title>
2261
2262    <tgroup cols=4>
2263     <thead>
2264      <row>
2265       <entry>Name</entry>
2266       <entry>Type</entry>
2267       <entry>References</entry>
2268       <entry>Description</entry>
2269      </row>
2270     </thead>
2271
2272     <tbody>
2273      <row>
2274       <entry><structfield>classid</structfield></entry>
2275       <entry><type>oid</type></entry>
2276       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2277       <entry>The OID of the system catalog the dependent object is in</entry>
2278      </row>
2279
2280      <row>
2281       <entry><structfield>objid</structfield></entry>
2282       <entry><type>oid</type></entry>
2283       <entry>any OID column</entry>
2284       <entry>The OID of the specific dependent object</entry>
2285      </row>
2286
2287      <row>
2288       <entry><structfield>objsubid</structfield></entry>
2289       <entry><type>int4</type></entry>
2290       <entry></entry>
2291       <entry>
2292        For a table column, this is the column number (the
2293        <structfield>objid</> and <structfield>classid</> refer to the
2294        table itself).  For all other object types, this column is
2295        zero
2296       </entry>
2297      </row>
2298
2299      <row>
2300       <entry><structfield>refclassid</structfield></entry>
2301       <entry><type>oid</type></entry>
2302       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2303       <entry>The OID of the system catalog the referenced object is in</entry>
2304      </row>
2305
2306      <row>
2307       <entry><structfield>refobjid</structfield></entry>
2308       <entry><type>oid</type></entry>
2309       <entry>any OID column</entry>
2310       <entry>The OID of the specific referenced object</entry>
2311      </row>
2312
2313      <row>
2314       <entry><structfield>refobjsubid</structfield></entry>
2315       <entry><type>int4</type></entry>
2316       <entry></entry>
2317       <entry>
2318        For a table column, this is the column number (the
2319        <structfield>refobjid</> and <structfield>refclassid</> refer
2320        to the table itself).  For all other object types, this column
2321        is zero
2322       </entry>
2323      </row>
2324
2325      <row>
2326       <entry><structfield>deptype</structfield></entry>
2327       <entry><type>char</type></entry>
2328       <entry></entry>
2329       <entry>
2330        A code defining the specific semantics of this dependency relationship; see text
2331       </entry>
2332      </row>
2333
2334     </tbody>
2335    </tgroup>
2336   </table>
2337
2338   <para>
2339    In all cases, a <structname>pg_depend</structname> entry indicates that the
2340    referenced object cannot be dropped without also dropping the dependent
2341    object.  However, there are several subflavors identified by
2342    <structfield>deptype</>:
2343
2344    <variablelist>
2345     <varlistentry>
2346      <term><symbol>DEPENDENCY_NORMAL</> (<literal>n</>)</term>
2347      <listitem>
2348       <para>
2349        A normal relationship between separately-created objects.  The
2350        dependent object can be dropped without affecting the
2351        referenced object.  The referenced object can only be dropped
2352        by specifying <literal>CASCADE</>, in which case the dependent
2353        object is dropped, too.  Example: a table column has a normal
2354        dependency on its data type.
2355       </para>
2356      </listitem>
2357     </varlistentry>
2358
2359     <varlistentry>
2360      <term><symbol>DEPENDENCY_AUTO</> (<literal>a</>)</term>
2361      <listitem>
2362       <para>
2363        The dependent object can be dropped separately from the
2364        referenced object, and should be automatically dropped
2365        (regardless of <literal>RESTRICT</> or <literal>CASCADE</>
2366        mode) if the referenced object is dropped.  Example: a named
2367        constraint on a table is made autodependent on the table, so
2368        that it will go away if the table is dropped.
2369       </para>
2370      </listitem>
2371     </varlistentry>
2372
2373     <varlistentry>
2374      <term><symbol>DEPENDENCY_INTERNAL</> (<literal>i</>)</term>
2375      <listitem>
2376       <para>
2377        The dependent object was created as part of creation of the
2378        referenced object, and is really just a part of its internal
2379        implementation.  A <command>DROP</> of the dependent object
2380        will be disallowed outright (we'll tell the user to issue a
2381        <command>DROP</> against the referenced object, instead).  A
2382        <command>DROP</> of the referenced object will be propagated
2383        through to drop the dependent object whether
2384        <command>CASCADE</> is specified or not.  Example: a trigger
2385        that's created to enforce a foreign-key constraint is made
2386        internally dependent on the constraint's
2387        <structname>pg_constraint</> entry.
2388       </para>
2389      </listitem>
2390     </varlistentry>
2391
2392     <varlistentry>
2393      <term><symbol>DEPENDENCY_PIN</> (<literal>p</>)</term>
2394      <listitem>
2395       <para>
2396        There is no dependent object; this type of entry is a signal
2397        that the system itself depends on the referenced object, and so
2398        that object must never be deleted.  Entries of this type are
2399        created only by <command>initdb</command>.  The columns for the
2400        dependent object contain zeroes.
2401       </para>
2402      </listitem>
2403     </varlistentry>
2404    </variablelist>
2405
2406    Other dependency flavors might be needed in future.
2407   </para>
2408
2409  </sect1>
2410
2411
2412  <sect1 id="catalog-pg-description">
2413   <title><structname>pg_description</structname></title>
2414
2415   <indexterm zone="catalog-pg-description">
2416    <primary>pg_description</primary>
2417   </indexterm>
2418
2419   <para>
2420    The catalog <structname>pg_description</> stores optional descriptions
2421    (comments) for each database object.  Descriptions can be manipulated
2422    with the <xref linkend="sql-comment" endterm="sql-comment-title"> command and viewed with
2423    <application>psql</application>'s <literal>\d</literal> commands.
2424    Descriptions of many built-in system objects are provided in the initial
2425    contents of <structname>pg_description</structname>.
2426   </para>
2427
2428   <para>
2429    See also <link linkend="catalog-pg-shdescription"><structname>pg_shdescription</structname></link>,
2430    which performs a similar function for descriptions involving objects that
2431    are shared across a database cluster.
2432   </para>
2433
2434   <table>
2435    <title><structname>pg_description</> Columns</title>
2436
2437    <tgroup cols=4>
2438     <thead>
2439      <row>
2440       <entry>Name</entry>
2441       <entry>Type</entry>
2442       <entry>References</entry>
2443       <entry>Description</entry>
2444      </row>
2445     </thead>
2446
2447     <tbody>
2448      <row>
2449       <entry><structfield>objoid</structfield></entry>
2450       <entry><type>oid</type></entry>
2451       <entry>any OID column</entry>
2452       <entry>The OID of the object this description pertains to</entry>
2453      </row>
2454
2455      <row>
2456       <entry><structfield>classoid</structfield></entry>
2457       <entry><type>oid</type></entry>
2458       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2459       <entry>The OID of the system catalog this object appears in</entry>
2460      </row>
2461
2462      <row>
2463       <entry><structfield>objsubid</structfield></entry>
2464       <entry><type>int4</type></entry>
2465       <entry></entry>
2466       <entry>
2467        For a comment on a table column, this is the column number (the
2468        <structfield>objoid</> and <structfield>classoid</> refer to
2469        the table itself).  For all other object types, this column is
2470        zero
2471       </entry>
2472      </row>
2473
2474      <row>
2475       <entry><structfield>description</structfield></entry>
2476       <entry><type>text</type></entry>
2477       <entry></entry>
2478       <entry>Arbitrary text that serves as the description of this object</entry>
2479      </row>
2480     </tbody>
2481    </tgroup>
2482   </table>
2483
2484  </sect1>
2485
2486
2487  <sect1 id="catalog-pg-enum">
2488   <title><structname>pg_enum</structname></title>
2489
2490   <indexterm zone="catalog-pg-enum">
2491    <primary>pg_enum</primary>
2492   </indexterm>
2493
2494   <para>
2495    The <structname>pg_enum</structname> catalog contains entries
2496    matching enum types to their associated values and labels. The
2497    internal representation of a given enum value is actually the OID
2498    of its associated row in <structname>pg_enum</structname>.  The
2499    OIDs for a particular enum type are guaranteed to be ordered in
2500    the way the type should sort, but there is no guarantee about the
2501    ordering of OIDs of unrelated enum types.
2502   </para>
2503
2504   <table>
2505    <title><structname>pg_enum</> Columns</title>
2506
2507    <tgroup cols=4>
2508     <thead>
2509      <row>
2510       <entry>Name</entry>
2511       <entry>Type</entry>
2512       <entry>References</entry>
2513       <entry>Description</entry>
2514      </row>
2515     </thead>
2516
2517     <tbody>
2518      <row>
2519       <entry><structfield>enumtypid</structfield></entry>
2520       <entry><type>oid</type></entry>
2521       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
2522       <entry>The OID of the <structname>pg_type</> entry owning this enum value</entry>
2523      </row>
2524
2525      <row>
2526       <entry><structfield>enumlabel</structfield></entry>
2527       <entry><type>name</type></entry>
2528       <entry></entry>
2529       <entry>The textual label for this enum value</entry>
2530      </row>
2531     </tbody>
2532    </tgroup>
2533   </table>
2534  </sect1>
2535
2536
2537  <sect1 id="catalog-pg-index">
2538   <title><structname>pg_index</structname></title>
2539
2540   <indexterm zone="catalog-pg-index">
2541    <primary>pg_index</primary>
2542   </indexterm>
2543
2544   <para>
2545    The catalog <structname>pg_index</structname> contains part of the information
2546    about indexes.  The rest is mostly in
2547    <structname>pg_class</structname>.
2548   </para>
2549
2550   <table>
2551    <title><structname>pg_index</> Columns</title>
2552
2553    <tgroup cols=4>
2554     <thead>
2555      <row>
2556       <entry>Name</entry>
2557       <entry>Type</entry>
2558       <entry>References</entry>
2559       <entry>Description</entry>
2560      </row>
2561     </thead>
2562
2563     <tbody>
2564      <row>
2565       <entry><structfield>indexrelid</structfield></entry>
2566       <entry><type>oid</type></entry>
2567       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2568       <entry>The OID of the <structname>pg_class</> entry for this index</entry>
2569      </row>
2570
2571      <row>
2572       <entry><structfield>indrelid</structfield></entry>
2573       <entry><type>oid</type></entry>
2574       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2575       <entry>The OID of the <structname>pg_class</> entry for the table this index is for</entry>
2576      </row>
2577
2578      <row>
2579       <entry><structfield>indnatts</structfield></entry>
2580       <entry><type>int2</type></entry>
2581       <entry></entry>
2582       <entry>The number of columns in the index (duplicates
2583       <literal>pg_class.relnatts</literal>)</entry>
2584      </row>
2585
2586      <row>
2587       <entry><structfield>indisunique</structfield></entry>
2588       <entry><type>bool</type></entry>
2589       <entry></entry>
2590       <entry>If true, this is a unique index</entry>
2591      </row>
2592
2593      <row>
2594       <entry><structfield>indisprimary</structfield></entry>
2595       <entry><type>bool</type></entry>
2596       <entry></entry>
2597       <entry>If true, this index represents the primary key of the table
2598       (<structfield>indisunique</> should always be true when this is true)</entry>
2599      </row>
2600
2601      <row>
2602       <entry><structfield>indisclustered</structfield></entry>
2603       <entry><type>bool</type></entry>
2604       <entry></entry>
2605       <entry>If true, the table was last clustered on this index</entry>
2606      </row>
2607
2608      <row>
2609       <entry><structfield>indisvalid</structfield></entry>
2610       <entry><type>bool</type></entry>
2611       <entry></entry>
2612       <entry>
2613        If true, the index is currently valid for queries.  False means the
2614        index is possibly incomplete: it must still be modified by
2615        <command>INSERT</>/<command>UPDATE</> operations, but it cannot safely
2616        be used for queries. If it is unique, the uniqueness property is not
2617        true either
2618       </entry>
2619      </row>
2620
2621      <row>
2622       <entry><structfield>indcheckxmin</structfield></entry>
2623       <entry><type>bool</type></entry>
2624       <entry></entry>
2625       <entry>
2626        If true, queries must not use the index until the <structfield>xmin</>
2627        of this <structname>pg_index</> row is below their TransactionXmin
2628        event horizon, because the table may contain broken HOT chains with
2629        incompatible rows that they can see
2630       </entry>
2631      </row>
2632
2633      <row>
2634       <entry><structfield>indisready</structfield></entry>
2635       <entry><type>bool</type></entry>
2636       <entry></entry>
2637       <entry>
2638        If true, the index is currently ready for inserts.  False means the
2639        index must be ignored by <command>INSERT</>/<command>UPDATE</>
2640        operations
2641       </entry>
2642      </row>
2643
2644      <row>
2645       <entry><structfield>indkey</structfield></entry>
2646       <entry><type>int2vector</type></entry>
2647       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
2648       <entry>
2649        This is an array of <structfield>indnatts</structfield> values that
2650        indicate which table columns this index indexes.  For example a value
2651        of <literal>1 3</literal> would mean that the first and the third table
2652        columns make up the index key.  A zero in this array indicates that the
2653        corresponding index attribute is an expression over the table columns,
2654        rather than a simple column reference
2655       </entry>
2656      </row>
2657
2658      <row>
2659       <entry><structfield>indclass</structfield></entry>
2660       <entry><type>oidvector</type></entry>
2661       <entry><literal><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.oid</literal></entry>
2662       <entry>
2663        For each column in the index key, this contains the OID of
2664        the operator class to use.  See
2665        <link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link> for details
2666       </entry>
2667      </row>
2668
2669      <row>
2670       <entry><structfield>indoption</structfield></entry>
2671       <entry><type>int2vector</type></entry>
2672       <entry></entry>
2673       <entry>
2674        This is an array of <structfield>indnatts</structfield> values that
2675        store per-column flag bits.  The meaning of the bits is defined by
2676        the index's access method
2677       </entry>
2678      </row>
2679
2680      <row>
2681       <entry><structfield>indexprs</structfield></entry>
2682       <entry><type>text</type></entry>
2683       <entry></entry>
2684       <entry>Expression trees (in <function>nodeToString()</function> representation)
2685       for index attributes that are not simple column references.  This is a
2686       list with one element for each zero entry in <structfield>indkey</>.
2687       NULL if all index attributes are simple references</entry>
2688      </row>
2689
2690      <row>
2691       <entry><structfield>indpred</structfield></entry>
2692       <entry><type>text</type></entry>
2693       <entry></entry>
2694       <entry>Expression tree (in <function>nodeToString()</function> representation)
2695       for partial index predicate.  NULL if not a partial index</entry>
2696      </row>
2697     </tbody>
2698    </tgroup>
2699   </table>
2700
2701  </sect1>
2702
2703
2704  <sect1 id="catalog-pg-inherits">
2705   <title><structname>pg_inherits</structname></title>
2706
2707   <indexterm zone="catalog-pg-inherits">
2708    <primary>pg_inherits</primary>
2709   </indexterm>
2710
2711   <para>
2712    The catalog <structname>pg_inherits</> records information about
2713    table inheritance hierarchies.  There is one entry for each direct
2714    child table in the database.  (Indirect inheritance can be determined
2715    by following chains of entries.)
2716   </para>
2717
2718   <table>
2719    <title><structname>pg_inherits</> Columns</title>
2720
2721    <tgroup cols=4>
2722     <thead>
2723      <row>
2724       <entry>Name</entry>
2725       <entry>Type</entry>
2726       <entry>References</entry>
2727       <entry>Description</entry>
2728      </row>
2729     </thead>
2730
2731     <tbody>
2732      <row>
2733       <entry><structfield>inhrelid</structfield></entry>
2734       <entry><type>oid</type></entry>
2735       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2736       <entry>
2737        The OID of the child table
2738       </entry>
2739      </row>
2740
2741      <row>
2742       <entry><structfield>inhparent</structfield></entry>
2743       <entry><type>oid</type></entry>
2744       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2745       <entry>
2746        The OID of the parent table
2747       </entry>
2748      </row>
2749
2750      <row>
2751       <entry><structfield>inhseqno</structfield></entry>
2752       <entry><type>int4</type></entry>
2753       <entry></entry>
2754       <entry>
2755        If there is more than one direct parent for a child table (multiple
2756        inheritance), this number tells the order in which the
2757        inherited columns are to be arranged.  The count starts at 1
2758       </entry>
2759      </row>
2760     </tbody>
2761    </tgroup>
2762   </table>
2763
2764  </sect1>
2765
2766
2767  <sect1 id="catalog-pg-language">
2768   <title><structname>pg_language</structname></title>
2769
2770   <indexterm zone="catalog-pg-language">
2771    <primary>pg_language</primary>
2772   </indexterm>
2773
2774   <para>
2775    The catalog <structname>pg_language</structname> registers
2776    languages in which you can write functions or stored procedures.
2777    See <xref linkend="sql-createlanguage" endterm="sql-createlanguage-title">
2778    and <xref linkend="xplang"> for more information about language handlers.
2779   </para>
2780
2781   <table>
2782    <title><structname>pg_language</> Columns</title>
2783
2784    <tgroup cols=4>
2785     <thead>
2786      <row>
2787       <entry>Name</entry>
2788       <entry>Type</entry>
2789       <entry>References</entry>
2790       <entry>Description</entry>
2791      </row>
2792     </thead>
2793
2794     <tbody>
2795      <row>
2796       <entry><structfield>lanname</structfield></entry>
2797       <entry><type>name</type></entry>
2798       <entry></entry>
2799       <entry>Name of the language</entry>
2800      </row>
2801
2802      <row>
2803       <entry><structfield>lanowner</structfield></entry>
2804       <entry><type>oid</type></entry>
2805       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2806       <entry>Owner of the language</entry>
2807      </row>
2808
2809      <row>
2810       <entry><structfield>lanispl</structfield></entry>
2811       <entry><type>bool</type></entry>
2812       <entry></entry>
2813       <entry>
2814        This is false for internal languages (such as
2815        <acronym>SQL</acronym>) and true for user-defined languages.
2816        Currently, <application>pg_dump</application> still uses this
2817        to determine which languages need to be dumped, but this might be
2818        replaced by a different mechanism in the future
2819       </entry>
2820      </row>
2821
2822      <row>
2823       <entry><structfield>lanpltrusted</structfield></entry>
2824       <entry><type>bool</type></entry>
2825       <entry></entry>
2826       <entry>
2827        True if this is a trusted language, which means that it is believed
2828        not to grant access to anything outside the normal SQL execution
2829        environment.  Only superusers can create functions in untrusted
2830        languages
2831       </entry>
2832      </row>
2833
2834      <row>
2835       <entry><structfield>lanplcallfoid</structfield></entry>
2836       <entry><type>oid</type></entry>
2837       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2838       <entry>
2839        For noninternal languages this references the language
2840        handler, which is a special function that is responsible for
2841        executing all functions that are written in the particular
2842        language
2843       </entry>
2844      </row>
2845
2846      <row>
2847       <entry><structfield>lanvalidator</structfield></entry>
2848       <entry><type>oid</type></entry>
2849       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2850       <entry>
2851        This references a language validator function that is responsible
2852        for checking the syntax and validity of new functions when they
2853        are created.  Zero if no validator is provided
2854       </entry>
2855      </row>
2856
2857      <row>
2858       <entry><structfield>lanacl</structfield></entry>
2859       <entry><type>aclitem[]</type></entry>
2860       <entry></entry>
2861       <entry>
2862        Access privileges; see
2863        <xref linkend="sql-grant" endterm="sql-grant-title"> and
2864        <xref linkend="sql-revoke" endterm="sql-revoke-title">
2865        for details
2866       </entry>
2867      </row>
2868     </tbody>
2869    </tgroup>
2870   </table>
2871
2872  </sect1>
2873
2874
2875  <sect1 id="catalog-pg-largeobject">
2876   <title><structname>pg_largeobject</structname></title>
2877
2878   <indexterm zone="catalog-pg-largeobject">
2879    <primary>pg_largeobject</primary>
2880   </indexterm>
2881
2882   <para>
2883    The catalog <structname>pg_largeobject</structname> holds the data making up
2884    <quote>large objects</quote>.  A large object is identified by an
2885    OID assigned when it is created.  Each large object is broken into
2886    segments or <quote>pages</> small enough to be conveniently stored as rows
2887    in <structname>pg_largeobject</structname>.
2888    The amount of data per page is defined to be <symbol>LOBLKSIZE</> (which is currently
2889    <literal>BLCKSZ/4</>, or typically 2 kB).
2890   </para>
2891
2892   <table>
2893    <title><structname>pg_largeobject</> Columns</title>
2894
2895    <tgroup cols=3>
2896     <thead>
2897      <row>
2898       <entry>Name</entry>
2899       <entry>Type</entry>
2900       <entry>Description</entry>
2901      </row>
2902     </thead>
2903
2904     <tbody>
2905      <row>
2906       <entry><structfield>loid</structfield></entry>
2907       <entry><type>oid</type></entry>
2908       <entry>Identifier of the large object that includes this page</entry>
2909      </row>
2910
2911      <row>
2912       <entry><structfield>pageno</structfield></entry>
2913       <entry><type>int4</type></entry>
2914       <entry>Page number of this page within its large object
2915       (counting from zero)</entry>
2916      </row>
2917
2918      <row>
2919       <entry><structfield>data</structfield></entry>
2920       <entry><type>bytea</type></entry>
2921       <entry>
2922        Actual data stored in the large object.
2923        This will never be more than <symbol>LOBLKSIZE</> bytes and might be less
2924       </entry>
2925      </row>
2926     </tbody>
2927    </tgroup>
2928   </table>
2929
2930   <para>
2931    Each row of <structname>pg_largeobject</structname> holds data
2932    for one page of a large object, beginning at
2933    byte offset (<literal>pageno * LOBLKSIZE</>) within the object.  The implementation
2934    allows sparse storage: pages might be missing, and might be shorter than
2935    <literal>LOBLKSIZE</> bytes even if they are not the last page of the object.
2936    Missing regions within a large object read as zeroes.
2937   </para>
2938
2939  </sect1>
2940
2941
2942  <sect1 id="catalog-pg-listener">
2943   <title><structname>pg_listener</structname></title>
2944
2945   <indexterm zone="catalog-pg-listener">
2946    <primary>pg_listener</primary>
2947   </indexterm>
2948
2949   <para>
2950    The catalog <structname>pg_listener</structname> supports the
2951    <xref linkend="sql-listen" endterm="sql-listen-title"> and
2952    <xref linkend="sql-notify" endterm="sql-notify-title">
2953    commands.  A listener creates an entry in
2954    <structname>pg_listener</structname> for each notification name
2955    it is listening for.  A notifier scans <structname>pg_listener</structname>
2956    and updates each matching entry to show that a notification has occurred.
2957    The notifier also sends a signal (using the PID recorded in the table)
2958    to awaken the listener from sleep.
2959   </para>
2960
2961   <table>
2962    <title><structname>pg_listener</> Columns</title>
2963
2964    <tgroup cols=4>
2965     <thead>
2966      <row>
2967       <entry>Name</entry>
2968       <entry>Type</entry>
2969       <entry>References</entry>
2970       <entry>Description</entry>
2971      </row>
2972     </thead>
2973
2974     <tbody>
2975      <row>
2976       <entry><structfield>relname</structfield></entry>
2977       <entry><type>name</type></entry>
2978       <entry>
2979        Notify condition name.  (The name need not match any actual
2980        relation in the database; the name <structfield>relname</> is historical.)
2981       </entry>
2982      </row>
2983
2984      <row>
2985       <entry><structfield>listenerpid</structfield></entry>
2986       <entry><type>int4</type></entry>
2987       <entry>PID of the server process that created this entry</entry>
2988      </row>
2989
2990      <row>
2991       <entry><structfield>notification</structfield></entry>
2992       <entry><type>int4</type></entry>
2993       <entry>
2994        Zero if no event is pending for this listener.  If an event is
2995        pending, the PID of the server process that sent the notification
2996       </entry>
2997      </row>
2998     </tbody>
2999    </tgroup>
3000   </table>
3001
3002  </sect1>
3003
3004
3005  <sect1 id="catalog-pg-namespace">
3006   <title><structname>pg_namespace</structname></title>
3007
3008   <indexterm zone="catalog-pg-namespace">
3009    <primary>pg_namespace</primary>
3010   </indexterm>
3011
3012   <para>
3013    The catalog <structname>pg_namespace</> stores namespaces.
3014    A namespace is the structure underlying SQL schemas: each namespace
3015    can have a separate collection of relations, types, etc. without name
3016    conflicts.
3017   </para>
3018
3019   <table>
3020    <title><structname>pg_namespace</> Columns</title>
3021
3022    <tgroup cols=4>
3023     <thead>
3024      <row>
3025       <entry>Name</entry>
3026       <entry>Type</entry>
3027       <entry>References</entry>
3028       <entry>Description</entry>
3029      </row>
3030     </thead>
3031
3032     <tbody>
3033      <row>
3034       <entry><structfield>nspname</structfield></entry>
3035       <entry><type>name</type></entry>
3036       <entry></entry>
3037       <entry>Name of the namespace</entry>
3038      </row>
3039
3040      <row>
3041       <entry><structfield>nspowner</structfield></entry>
3042       <entry><type>oid</type></entry>
3043       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3044       <entry>Owner of the namespace</entry>
3045      </row>
3046
3047      <row>
3048       <entry><structfield>nspacl</structfield></entry>
3049       <entry><type>aclitem[]</type></entry>
3050       <entry></entry>
3051       <entry>
3052        Access privileges; see
3053        <xref linkend="sql-grant" endterm="sql-grant-title"> and
3054        <xref linkend="sql-revoke" endterm="sql-revoke-title">
3055        for details
3056       </entry>
3057      </row>
3058     </tbody>
3059    </tgroup>
3060   </table>
3061
3062  </sect1>
3063
3064
3065  <sect1 id="catalog-pg-opclass">
3066   <title><structname>pg_opclass</structname></title>
3067
3068   <indexterm zone="catalog-pg-opclass">
3069    <primary>pg_opclass</primary>
3070   </indexterm>
3071
3072   <para>
3073    The catalog <structname>pg_opclass</structname> defines
3074    index access method operator classes.  Each operator class defines
3075    semantics for index columns of a particular data type and a particular
3076    index access method.  An operator class essentially specifies that a
3077    particular operator family is applicable to a particular indexable column
3078    data type.  The set of operators from the family that are actually usable
3079    with the indexed column are whichever ones accept the column's data type
3080    as their lefthand input.
3081   </para>
3082
3083   <para>
3084    Operator classes are described at length in <xref linkend="xindex">.
3085   </para>
3086
3087   <table>
3088    <title><structname>pg_opclass</> Columns</title>
3089
3090    <tgroup cols=4>
3091     <thead>
3092      <row>
3093       <entry>Name</entry>
3094       <entry>Type</entry>
3095       <entry>References</entry>
3096       <entry>Description</entry>
3097      </row>
3098     </thead>
3099     <tbody>
3100
3101      <row>
3102       <entry><structfield>opcmethod</structfield></entry>
3103       <entry><type>oid</type></entry>
3104       <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
3105       <entry>Index access method operator class is for</entry>
3106      </row>
3107
3108      <row>
3109       <entry><structfield>opcname</structfield></entry>
3110       <entry><type>name</type></entry>
3111       <entry></entry>
3112       <entry>Name of this operator class</entry>
3113      </row>
3114
3115      <row>
3116       <entry><structfield>opcnamespace</structfield></entry>
3117       <entry><type>oid</type></entry>
3118       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3119       <entry>Namespace of this operator class</entry>
3120      </row>
3121
3122      <row>
3123       <entry><structfield>opcowner</structfield></entry>
3124       <entry><type>oid</type></entry>
3125       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3126       <entry>Owner of the operator class</entry>
3127      </row>
3128
3129      <row>
3130       <entry><structfield>opcfamily</structfield></entry>
3131       <entry><type>oid</type></entry>
3132       <entry><literal><link linkend="catalog-pg-opfamily"><structname>pg_opfamily</structname></link>.oid</literal></entry>
3133       <entry>Operator family containing the operator class</entry>
3134      </row>
3135
3136      <row>
3137       <entry><structfield>opcintype</structfield></entry>
3138       <entry><type>oid</type></entry>
3139       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3140       <entry>Data type that the operator class indexes</entry>
3141      </row>
3142
3143      <row>
3144       <entry><structfield>opcdefault</structfield></entry>
3145       <entry><type>bool</type></entry>
3146       <entry></entry>
3147       <entry>True if this operator class is the default for <structfield>opcintype</></entry>
3148      </row>
3149
3150      <row>
3151       <entry><structfield>opckeytype</structfield></entry>
3152       <entry><type>oid</type></entry>
3153       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3154       <entry>Type of data stored in index, or zero if same as <structfield>opcintype</></entry>
3155      </row>
3156
3157     </tbody>
3158    </tgroup>
3159   </table>
3160
3161   <para>
3162    An operator class's <structfield>opcmethod</> must match the
3163    <structname>opfmethod</> of its containing operator family.
3164    Also, there must be no more than one <structname>pg_opclass</structname>
3165    row having <structname>opcdefault</> true for any given combination of
3166    <structname>opcmethod</> and <structname>opcintype</>.
3167   </para>
3168
3169  </sect1>
3170
3171
3172  <sect1 id="catalog-pg-operator">
3173   <title><structname>pg_operator</structname></title>
3174
3175   <indexterm zone="catalog-pg-operator">
3176    <primary>pg_operator</primary>
3177   </indexterm>
3178
3179   <para>
3180    The catalog <structname>pg_operator</> stores information about operators.
3181    See <xref linkend="sql-createoperator" endterm="sql-createoperator-title">
3182    and <xref linkend="xoper"> for more information.
3183   </para>
3184
3185   <table>
3186    <title><structname>pg_operator</> Columns</title>
3187
3188    <tgroup cols=4>
3189     <thead>
3190      <row>
3191       <entry>Name</entry>
3192       <entry>Type</entry>
3193       <entry>References</entry>
3194       <entry>Description</entry>
3195      </row>
3196     </thead>
3197
3198     <tbody>
3199      <row>
3200       <entry><structfield>oprname</structfield></entry>
3201       <entry><type>name</type></entry>
3202       <entry></entry>
3203       <entry>Name of the operator</entry>
3204      </row>
3205
3206      <row>
3207       <entry><structfield>oprnamespace</structfield></entry>
3208       <entry><type>oid</type></entry>
3209       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3210       <entry>
3211        The OID of the namespace that contains this operator
3212       </entry>
3213      </row>
3214
3215      <row>
3216       <entry><structfield>oprowner</structfield></entry>
3217       <entry><type>oid</type></entry>
3218       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3219       <entry>Owner of the operator</entry>
3220      </row>
3221
3222      <row>
3223       <entry><structfield>oprkind</structfield></entry>
3224       <entry><type>char</type></entry>
3225       <entry></entry>
3226       <entry>
3227        <literal>b</> = infix (<quote>both</quote>), <literal>l</> = prefix
3228        (<quote>left</quote>), <literal>r</> = postfix (<quote>right</quote>)
3229       </entry>
3230      </row>
3231
3232      <row>
3233       <entry><structfield>oprcanmerge</structfield></entry>
3234       <entry><type>bool</type></entry>
3235       <entry></entry>
3236       <entry>This operator supports merge joins</entry>
3237      </row>
3238
3239      <row>
3240       <entry><structfield>oprcanhash</structfield></entry>
3241       <entry><type>bool</type></entry>
3242       <entry></entry>
3243       <entry>This operator supports hash joins</entry>
3244      </row>
3245
3246      <row>
3247       <entry><structfield>oprleft</structfield></entry>
3248       <entry><type>oid</type></entry>
3249       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3250       <entry>Type of the left operand</entry>
3251      </row>
3252
3253      <row>
3254       <entry><structfield>oprright</structfield></entry>
3255       <entry><type>oid</type></entry>
3256       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3257       <entry>Type of the right operand</entry>
3258      </row>
3259
3260      <row>
3261       <entry><structfield>oprresult</structfield></entry>
3262       <entry><type>oid</type></entry>
3263       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3264       <entry>Type of the result</entry>
3265      </row>
3266
3267      <row>
3268       <entry><structfield>oprcom</structfield></entry>
3269       <entry><type>oid</type></entry>
3270       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3271       <entry>Commutator of this operator, if any</entry>
3272      </row>
3273
3274      <row>
3275       <entry><structfield>oprnegate</structfield></entry>
3276       <entry><type>oid</type></entry>
3277       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3278       <entry>Negator of this operator, if any</entry>
3279      </row>
3280
3281      <row>
3282       <entry><structfield>oprcode</structfield></entry>
3283       <entry><type>regproc</type></entry>
3284       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3285       <entry>Function that implements this operator</entry>
3286      </row>
3287
3288      <row>
3289       <entry><structfield>oprrest</structfield></entry>
3290       <entry><type>regproc</type></entry>
3291       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3292       <entry>Restriction selectivity estimation function for this operator</entry>
3293      </row>
3294
3295      <row>
3296       <entry><structfield>oprjoin</structfield></entry>
3297       <entry><type>regproc</type></entry>
3298       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3299       <entry>Join selectivity estimation function for this operator</entry>
3300      </row>
3301     </tbody>
3302    </tgroup>
3303   </table>
3304
3305   <para>
3306    Unused column contain zeroes. For example, <structfield>oprleft</structfield>
3307    is zero for a prefix operator.
3308   </para>
3309
3310  </sect1>
3311
3312
3313  <sect1 id="catalog-pg-opfamily">
3314   <title><structname>pg_opfamily</structname></title>
3315
3316   <indexterm zone="catalog-pg-opfamily">
3317    <primary>pg_opfamily</primary>
3318   </indexterm>
3319
3320   <para>
3321    The catalog <structname>pg_opfamily</structname> defines operator families.
3322    Each operator family is a collection of operators and associated
3323    support routines that implement the semantics specified for a particular
3324    index access method.  Furthermore, the operators in a family are all
3325    <quote>compatible</>, in a way that is specified by the access method.
3326    The operator family concept allows cross-data-type operators to be used
3327    with indexes and to be reasoned about using knowledge of access method
3328    semantics.
3329   </para>
3330
3331   <para>
3332    Operator families are described at length in <xref linkend="xindex">.
3333   </para>
3334
3335   <table>
3336    <title><structname>pg_opfamily</> Columns</title>
3337
3338    <tgroup cols=4>
3339     <thead>
3340      <row>
3341       <entry>Name</entry>
3342       <entry>Type</entry>
3343       <entry>References</entry>
3344       <entry>Description</entry>
3345      </row>
3346     </thead>
3347     <tbody>
3348
3349      <row>
3350       <entry><structfield>opfmethod</structfield></entry>
3351       <entry><type>oid</type></entry>
3352       <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
3353       <entry>Index access method operator family is for</entry>
3354      </row>
3355
3356      <row>
3357       <entry><structfield>opfname</structfield></entry>
3358       <entry><type>name</type></entry>
3359       <entry></entry>
3360       <entry>Name of this operator family</entry>
3361      </row>
3362
3363      <row>
3364       <entry><structfield>opfnamespace</structfield></entry>
3365       <entry><type>oid</type></entry>
3366       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3367       <entry>Namespace of this operator family</entry>
3368      </row>
3369
3370      <row>
3371       <entry><structfield>opfowner</structfield></entry>
3372       <entry><type>oid</type></entry>
3373       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3374       <entry>Owner of the operator family</entry>
3375      </row>
3376
3377     </tbody>
3378    </tgroup>
3379   </table>
3380
3381   <para>
3382    The majority of the information defining an operator family is not in its
3383    <structname>pg_opfamily</structname> row, but in the associated rows in
3384    <link linkend="catalog-pg-amop"><structname>pg_amop</structname></link>,
3385    <link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link>,
3386    and
3387    <link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.
3388   </para>
3389
3390  </sect1>
3391
3392
3393  <sect1 id="catalog-pg-pltemplate">
3394   <title><structname>pg_pltemplate</structname></title>
3395
3396   <indexterm zone="catalog-pg-pltemplate">
3397    <primary>pg_pltemplate</primary>
3398   </indexterm>
3399
3400   <para>
3401    The catalog <structname>pg_pltemplate</structname> stores
3402    <quote>template</> information for procedural languages.
3403    A template for a language allows the language to be created in a
3404    particular database by a simple <command>CREATE LANGUAGE</> command,
3405    with no need to specify implementation details.
3406   </para>
3407
3408   <para>
3409    Unlike most system catalogs, <structname>pg_pltemplate</structname>
3410    is shared across all databases of a cluster: there is only one
3411    copy of <structname>pg_pltemplate</structname> per cluster, not
3412    one per database.  This allows the information to be accessible in
3413    each database as it is needed.
3414   </para>
3415
3416   <table>
3417    <title><structname>pg_pltemplate</> Columns</title>
3418
3419    <tgroup cols=3>
3420     <thead>
3421      <row>
3422       <entry>Name</entry>
3423       <entry>Type</entry>
3424       <entry>Description</entry>
3425      </row>
3426     </thead>
3427
3428     <tbody>
3429      <row>
3430       <entry><structfield>tmplname</structfield></entry>
3431       <entry><type>name</type></entry>
3432       <entry>Name of the language this template is for</entry>
3433      </row>
3434
3435      <row>
3436       <entry><structfield>tmpltrusted</structfield></entry>
3437       <entry><type>boolean</type></entry>
3438       <entry>True if language is considered trusted</entry>
3439      </row>
3440
3441      <row>
3442       <entry><structfield>tmpldbacreate</structfield></entry>
3443       <entry><type>boolean</type></entry>
3444       <entry>True if language may be created by a database owner</entry>
3445      </row>
3446
3447      <row>
3448       <entry><structfield>tmplhandler</structfield></entry>
3449       <entry><type>text</type></entry>
3450       <entry>Name of call handler function</entry>
3451      </row>
3452
3453      <row>
3454       <entry><structfield>tmplvalidator</structfield></entry>
3455       <entry><type>text</type></entry>
3456       <entry>Name of validator function, or NULL if none</entry>
3457      </row>
3458
3459      <row>
3460       <entry><structfield>tmpllibrary</structfield></entry>
3461       <entry><type>text</type></entry>
3462       <entry>Path of shared library that implements language</entry>
3463      </row>
3464
3465      <row>
3466       <entry><structfield>tmplacl</structfield></entry>
3467       <entry><type>aclitem[]</type></entry>
3468       <entry>Access privileges for template (not yet used)</entry>
3469      </row>
3470
3471     </tbody>
3472    </tgroup>
3473   </table>
3474
3475   <para>
3476    There are not currently any commands that manipulate procedural language
3477    templates; to change the built-in information, a superuser must modify
3478    the table using ordinary <command>INSERT</command>, <command>DELETE</command>,
3479    or <command>UPDATE</command> commands.  It is likely that a future
3480    release of <productname>PostgreSQL</productname> will offer
3481    commands to change the entries in a cleaner fashion.
3482   </para>
3483
3484   <para>
3485    When implemented, the <structfield>tmplacl</structfield> field will provide
3486    access control for the template itself (i.e., the right to create a
3487    language using it), not for the languages created from the template.
3488   </para>
3489
3490  </sect1>
3491
3492
3493  <sect1 id="catalog-pg-proc">
3494   <title><structname>pg_proc</structname></title>
3495
3496   <indexterm zone="catalog-pg-proc">
3497    <primary>pg_proc</primary>
3498   </indexterm>
3499
3500   <para>
3501    The catalog <structname>pg_proc</> stores information about functions (or procedures).
3502    See <xref linkend="sql-createfunction" endterm="sql-createfunction-title">
3503    and <xref linkend="xfunc"> for more information.
3504   </para>
3505
3506   <para>
3507    The table contains data for aggregate functions as well as plain functions.
3508    If <structfield>proisagg</structfield> is true, there should be a matching
3509    row in <structfield>pg_aggregate</structfield>.
3510   </para>
3511
3512   <table>
3513    <title><structname>pg_proc</> Columns</title>
3514
3515    <tgroup cols=4>
3516     <thead>
3517      <row>
3518       <entry>Name</entry>
3519       <entry>Type</entry>
3520       <entry>References</entry>
3521       <entry>Description</entry>
3522      </row>
3523     </thead>
3524
3525     <tbody>
3526      <row>
3527       <entry><structfield>proname</structfield></entry>
3528       <entry><type>name</type></entry>
3529       <entry></entry>
3530       <entry>Name of the function</entry>
3531      </row>
3532
3533      <row>
3534       <entry><structfield>pronamespace</structfield></entry>
3535       <entry><type>oid</type></entry>
3536       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3537       <entry>
3538        The OID of the namespace that contains this function
3539       </entry>
3540      </row>
3541
3542      <row>
3543       <entry><structfield>proowner</structfield></entry>
3544       <entry><type>oid</type></entry>
3545       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3546       <entry>Owner of the function</entry>
3547      </row>
3548
3549      <row>
3550       <entry><structfield>prolang</structfield></entry>
3551       <entry><type>oid</type></entry>
3552       <entry><literal><link linkend="catalog-pg-language"><structname>pg_language</structname></link>.oid</literal></entry>
3553       <entry>Implementation language or call interface of this function</entry>
3554      </row>
3555
3556      <row>
3557       <entry><structfield>procost</structfield></entry>
3558       <entry><type>float4</type></entry>
3559       <entry></entry>
3560       <entry>Estimated execution cost (in units of
3561        <xref linkend="guc-cpu-operator-cost">); if <structfield>proretset</>,
3562        this is cost per row returned</entry>
3563      </row>
3564
3565      <row>
3566       <entry><structfield>prorows</structfield></entry>
3567       <entry><type>float4</type></entry>
3568       <entry></entry>
3569       <entry>Estimated number of result rows (zero if not <structfield>proretset</>)</entry>
3570      </row>
3571
3572      <row>
3573       <entry><structfield>proisagg</structfield></entry>
3574       <entry><type>bool</type></entry>
3575       <entry></entry>
3576       <entry>Function is an aggregate function</entry>
3577      </row>
3578
3579      <row>
3580       <entry><structfield>prosecdef</structfield></entry>
3581       <entry><type>bool</type></entry>
3582       <entry></entry>
3583       <entry>Function is a security definer (i.e., a <quote>setuid</>
3584       function)</entry>
3585      </row>
3586
3587      <row>
3588       <entry><structfield>proisstrict</structfield></entry>
3589       <entry><type>bool</type></entry>
3590       <entry></entry>
3591       <entry>
3592        Function returns null if any call argument is null.  In that
3593        case the function won't actually be called at all.  Functions
3594        that are not <quote>strict</quote> must be prepared to handle
3595        null inputs
3596       </entry>
3597      </row>
3598
3599      <row>
3600       <entry><structfield>proretset</structfield></entry>
3601       <entry><type>bool</type></entry>
3602       <entry></entry>
3603       <entry>Function returns a set (i.e., multiple values of the specified
3604       data type)</entry>
3605      </row>
3606
3607      <row>
3608       <entry><structfield>provolatile</structfield></entry>
3609       <entry><type>char</type></entry>
3610       <entry></entry>
3611       <entry>
3612        <structfield>provolatile</structfield> tells whether the function's
3613        result depends only on its input arguments, or is affected by outside
3614        factors.
3615        It is <literal>i</literal> for <quote>immutable</> functions,
3616        which always deliver the same result for the same inputs.
3617        It is <literal>s</literal> for <quote>stable</> functions,
3618        whose results (for fixed inputs) do not change within a scan.
3619        It is <literal>v</literal> for <quote>volatile</> functions,
3620        whose results might change at any time.  (Use <literal>v</literal> also
3621        for functions with side-effects, so that calls to them cannot get
3622        optimized away.)
3623       </entry>
3624      </row>
3625
3626      <row>
3627       <entry><structfield>pronargs</structfield></entry>
3628       <entry><type>int2</type></entry>
3629       <entry></entry>
3630       <entry>Number of arguments</entry>
3631      </row>
3632
3633      <row>
3634       <entry><structfield>prorettype</structfield></entry>
3635       <entry><type>oid</type></entry>
3636       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3637       <entry>Data type of the return value</entry>
3638      </row>
3639
3640      <row>
3641       <entry><structfield>proargtypes</structfield></entry>
3642       <entry><type>oidvector</type></entry>
3643       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3644       <entry>
3645        An array with the data types of the function arguments.  This includes
3646        only input arguments (including <literal>INOUT</literal> arguments), and thus represents
3647        the call signature of the function
3648       </entry>
3649      </row>
3650
3651      <row>
3652       <entry><structfield>proallargtypes</structfield></entry>
3653       <entry><type>oid[]</type></entry>
3654       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3655       <entry>
3656        An array with the data types of the function arguments.  This includes
3657        all arguments (including <literal>OUT</literal> and <literal>INOUT</literal> arguments); however, if all the
3658        arguments are IN arguments, this field will be null.
3659        Note that subscripting is 1-based, whereas for historical reasons
3660        <structfield>proargtypes</> is subscripted from 0
3661       </entry>
3662      </row>
3663
3664      <row>
3665       <entry><structfield>proargmodes</structfield></entry>
3666       <entry><type>char[]</type></entry>
3667       <entry></entry>
3668       <entry>
3669         An array with the modes of the function arguments, encoded as
3670         <literal>i</literal> for <literal>IN</> arguments,
3671         <literal>o</literal> for <literal>OUT</> arguments,
3672         <literal>b</literal> for <literal>INOUT</> arguments.
3673         If all the arguments are <literal>IN</literal> arguments, this field will be null.
3674         Note that subscripts correspond to positions of
3675         <structfield>proallargtypes</> not <structfield>proargtypes</>
3676       </entry>
3677      </row>
3678
3679      <row>
3680       <entry><structfield>proargnames</structfield></entry>
3681       <entry><type>text[]</type></entry>
3682       <entry></entry>
3683       <entry>
3684         An array with the names of the function arguments.
3685         Arguments without a name are set to empty strings in the array.
3686         If none of the arguments have a name, this field will be null.
3687         Note that subscripts correspond to positions of
3688         <structfield>proallargtypes</> not <structfield>proargtypes</>
3689       </entry>
3690      </row>
3691
3692      <row>
3693       <entry><structfield>prosrc</structfield></entry>
3694       <entry><type>text</type></entry>
3695       <entry></entry>
3696       <entry>
3697        This tells the function handler how to invoke the function.  It
3698        might be the actual source code of the function for interpreted
3699        languages, a link symbol, a file name, or just about anything
3700        else, depending on the implementation language/call convention
3701       </entry>
3702      </row>
3703
3704      <row>
3705       <entry><structfield>probin</structfield></entry>
3706       <entry><type>bytea</type></entry>
3707       <entry></entry>
3708       <entry>
3709        Additional information about how to invoke the function.
3710        Again, the interpretation is language-specific
3711       </entry>
3712      </row>
3713
3714      <row>
3715       <entry><structfield>proconfig</structfield></entry>
3716       <entry><type>text[]</type></entry>
3717       <entry></entry>
3718       <entry>Function's local settings for run-time configuration variables</entry>
3719      </row>
3720
3721      <row>
3722       <entry><structfield>proacl</structfield></entry>
3723       <entry><type>aclitem[]</type></entry>
3724       <entry></entry>
3725       <entry>
3726        Access privileges; see
3727        <xref linkend="sql-grant" endterm="sql-grant-title"> and
3728        <xref linkend="sql-revoke" endterm="sql-revoke-title">
3729        for details
3730       </entry>
3731      </row>
3732     </tbody>
3733    </tgroup>
3734   </table>
3735
3736   <para>
3737    For compiled functions, both built-in and dynamically loaded,
3738    <structfield>prosrc</structfield> contains the function's C-language
3739    name (link symbol).  For all other currently-known language types,
3740    <structfield>prosrc</structfield> contains the function's source
3741    text.  <structfield>probin</structfield> is unused except for
3742    dynamically-loaded C functions, for which it gives the name of the
3743    shared library file containing the function.
3744   </para>
3745
3746  </sect1>
3747
3748  <sect1 id="catalog-pg-rewrite">
3749   <title><structname>pg_rewrite</structname></title>
3750
3751   <indexterm zone="catalog-pg-rewrite">
3752    <primary>pg_rewrite</primary>
3753   </indexterm>
3754
3755   <para>
3756    The catalog <structname>pg_rewrite</structname> stores rewrite rules for tables and views.
3757   </para>
3758
3759   <table>
3760    <title><structname>pg_rewrite</> Columns</title>
3761
3762    <tgroup cols=4>
3763     <thead>
3764      <row>
3765       <entry>Name</entry>
3766       <entry>Type</entry>
3767       <entry>References</entry>
3768       <entry>Description</entry>
3769      </row>
3770     </thead>
3771
3772     <tbody>
3773      <row>
3774       <entry><structfield>rulename</structfield></entry>
3775       <entry><type>name</type></entry>
3776       <entry></entry>
3777       <entry>Rule name</entry>
3778      </row>
3779
3780      <row>
3781       <entry><structfield>ev_class</structfield></entry>
3782       <entry><type>oid</type></entry>
3783       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3784       <entry>The table this rule is for</entry>
3785      </row>
3786
3787      <row>
3788       <entry><structfield>ev_attr</structfield></entry>
3789       <entry><type>int2</type></entry>
3790       <entry></entry>
3791       <entry>The column this rule is for (currently, always zero to
3792       indicate the whole table)</entry>
3793      </row>
3794
3795      <row>
3796       <entry><structfield>ev_type</structfield></entry>
3797       <entry><type>char</type></entry>
3798       <entry></entry>
3799       <entry>
3800        Event type that the rule is for: 1 = <command>SELECT</>, 2 =
3801        <command>UPDATE</>, 3 = <command>INSERT</>, 4 =
3802        <command>DELETE</>
3803       </entry>
3804      </row>
3805
3806      <row>
3807       <entry><structfield>ev_enabled</structfield></entry>
3808       <entry><type>char</type></entry>
3809       <entry></entry>
3810       <entry>
3811        Controls in which <xref linkend="guc-session-replication-role"> modes
3812        the rule fires.
3813        <literal>O</> = rule fires in <quote>origin</> and <quote>local</> modes,
3814        <literal>D</> = rule is disabled,
3815        <literal>R</> = rule fires in <quote>replica</> mode,
3816        <literal>A</> = rule fires always.
3817       </entry>
3818      </row>
3819
3820      <row>
3821       <entry><structfield>is_instead</structfield></entry>
3822       <entry><type>bool</type></entry>
3823       <entry></entry>
3824       <entry>True if the rule is an <literal>INSTEAD</literal> rule</entry>
3825      </row>
3826
3827      <row>
3828       <entry><structfield>ev_qual</structfield></entry>
3829       <entry><type>text</type></entry>
3830       <entry></entry>
3831       <entry>
3832        Expression tree (in the form of a
3833        <function>nodeToString()</function> representation) for the
3834        rule's qualifying condition
3835       </entry>
3836      </row>
3837
3838      <row>
3839       <entry><structfield>ev_action</structfield></entry>
3840       <entry><type>text</type></entry>
3841       <entry></entry>
3842       <entry>
3843        Query tree (in the form of a
3844        <function>nodeToString()</function> representation) for the
3845        rule's action
3846       </entry>
3847      </row>
3848     </tbody>
3849    </tgroup>
3850   </table>
3851
3852   <note>
3853    <para>
3854     <literal>pg_class.relhasrules</literal>
3855     must be true if a table has any rules in this catalog.
3856    </para>
3857   </note>
3858
3859  </sect1>
3860
3861
3862  <sect1 id="catalog-pg-shdepend">
3863   <title><structname>pg_shdepend</structname></title>
3864
3865   <indexterm zone="catalog-pg-shdepend">
3866    <primary>pg_shdepend</primary>
3867   </indexterm>
3868
3869   <para>
3870    The catalog <structname>pg_shdepend</structname> records the
3871    dependency relationships between database objects and shared objects,
3872    such as roles.  This information allows
3873    <productname>PostgreSQL</productname> to ensure that those objects are
3874    unreferenced before attempting to delete them.
3875   </para>
3876
3877   <para>
3878    See also <link linkend="catalog-pg-depend"><structname>pg_depend</structname></link>,
3879    which performs a similar function for dependencies involving objects
3880    within a single database.
3881   </para>
3882
3883   <para>
3884    Unlike most system catalogs, <structname>pg_shdepend</structname>
3885    is shared across all databases of a cluster: there is only one
3886    copy of <structname>pg_shdepend</structname> per cluster, not
3887    one per database.
3888   </para>
3889
3890   <table>
3891    <title><structname>pg_shdepend</> Columns</title>
3892
3893    <tgroup cols=4>
3894     <thead>
3895      <row>
3896       <entry>Name</entry>
3897       <entry>Type</entry>
3898       <entry>References</entry>
3899       <entry>Description</entry>
3900      </row>
3901     </thead>
3902
3903     <tbody>
3904      <row>
3905       <entry><structfield>dbid</structfield></entry>
3906       <entry><type>oid</type></entry>
3907       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
3908       <entry>The OID of the database the dependent object is in,
3909        or zero for a shared object</entry>
3910      </row>
3911
3912      <row>
3913       <entry><structfield>classid</structfield></entry>
3914       <entry><type>oid</type></entry>
3915       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3916       <entry>The OID of the system catalog the dependent object is in</entry>
3917      </row>
3918
3919      <row>
3920       <entry><structfield>objid</structfield></entry>
3921       <entry><type>oid</type></entry>
3922       <entry>any OID column</entry>
3923       <entry>The OID of the specific dependent object</entry>
3924      </row>
3925
3926      <row>
3927       <entry><structfield>refclassid</structfield></entry>
3928       <entry><type>oid</type></entry>
3929       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3930       <entry>The OID of the system catalog the referenced object is in
3931        (must be a shared catalog)</entry>
3932      </row>
3933
3934      <row>
3935       <entry><structfield>refobjid</structfield></entry>
3936       <entry><type>oid</type></entry>
3937       <entry>any OID column</entry>
3938       <entry>The OID of the specific referenced object</entry>
3939      </row>
3940
3941      <row>
3942       <entry><structfield>deptype</structfield></entry>
3943       <entry><type>char</type></entry>
3944       <entry></entry>
3945       <entry>
3946        A code defining the specific semantics of this dependency relationship; see text
3947       </entry>
3948      </row>
3949
3950     </tbody>
3951    </tgroup>
3952   </table>
3953
3954   <para>
3955    In all cases, a <structname>pg_shdepend</structname> entry indicates that
3956    the referenced object cannot be dropped without also dropping the dependent
3957    object.  However, there are several subflavors identified by
3958    <structfield>deptype</>:
3959
3960    <variablelist>
3961     <varlistentry>
3962      <term><symbol>SHARED_DEPENDENCY_OWNER</> (<literal>o</>)</term>
3963      <listitem>
3964       <para>
3965        The referenced object (which must be a role) is the owner of the
3966        dependent object.
3967       </para>
3968      </listitem>
3969     </varlistentry>
3970
3971     <varlistentry>
3972      <term><symbol>SHARED_DEPENDENCY_ACL</> (<literal>a</>)</term>
3973      <listitem>
3974       <para>
3975        The referenced object (which must be a role) is mentioned in the
3976        ACL (access control list, i.e., privileges list) of the
3977        dependent object.  (A <symbol>SHARED_DEPENDENCY_ACL</> entry is
3978        not made for the owner of the object, since the owner will have
3979        a <symbol>SHARED_DEPENDENCY_OWNER</> entry anyway.)
3980       </para>
3981      </listitem>
3982     </varlistentry>
3983
3984     <varlistentry>
3985      <term><symbol>SHARED_DEPENDENCY_PIN</> (<literal>p</>)</term>
3986      <listitem>
3987       <para>
3988        There is no dependent object; this type of entry is a signal
3989        that the system itself depends on the referenced object, and so
3990        that object must never be deleted.  Entries of this type are
3991        created only by <command>initdb</command>.  The columns for the
3992        dependent object contain zeroes.
3993       </para>
3994      </listitem>
3995     </varlistentry>
3996    </variablelist>
3997
3998    Other dependency flavors might be needed in future.  Note in particular
3999    that the current definition only supports roles as referenced objects.
4000   </para>
4001
4002  </sect1>
4003
4004  <sect1 id="catalog-pg-shdescription">
4005   <title><structname>pg_shdescription</structname></title>
4006
4007   <indexterm zone="catalog-pg-shdescription">
4008    <primary>pg_shdescription</primary>
4009   </indexterm>
4010
4011   <para>
4012    The catalog <structname>pg_shdescription</structname> stores optional
4013    descriptions (comments) for shared database objects.  Descriptions can be
4014    manipulated with the <xref linkend="sql-comment"
4015    endterm="sql-comment-title"> command and viewed with
4016    <application>psql</application>'s <literal>\d</literal> commands.
4017   </para>
4018
4019   <para>
4020    See also <link linkend="catalog-pg-description"><structname>pg_description</structname></link>,
4021    which performs a similar function for descriptions involving objects
4022    within a single database.
4023   </para>
4024
4025   <para>
4026    Unlike most system catalogs, <structname>pg_shdescription</structname>
4027    is shared across all databases of a cluster: there is only one
4028    copy of <structname>pg_shdescription</structname> per cluster, not
4029    one per database.
4030   </para>
4031
4032   <table>
4033    <title><structname>pg_shdescription</> Columns</title>
4034
4035    <tgroup cols=4>
4036     <thead>
4037      <row>
4038       <entry>Name</entry>
4039       <entry>Type</entry>
4040       <entry>References</entry>
4041       <entry>Description</entry>
4042      </row>
4043     </thead>
4044
4045     <tbody>
4046      <row>
4047       <entry><structfield>objoid</structfield></entry>
4048       <entry><type>oid</type></entry>
4049       <entry>any OID column</entry>
4050       <entry>The OID of the object this description pertains to</entry>
4051      </row>
4052
4053      <row>
4054       <entry><structfield>classoid</structfield></entry>
4055       <entry><type>oid</type></entry>
4056       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4057       <entry>The OID of the system catalog this object appears in</entry>
4058      </row>
4059
4060      <row>
4061       <entry><structfield>description</structfield></entry>
4062       <entry><type>text</type></entry>
4063       <entry></entry>
4064       <entry>Arbitrary text that serves as the description of this object</entry>
4065      </row>
4066     </tbody>
4067    </tgroup>
4068   </table>
4069
4070  </sect1>
4071
4072
4073  <sect1 id="catalog-pg-statistic">
4074   <title><structname>pg_statistic</structname></title>
4075
4076   <indexterm zone="catalog-pg-statistic">
4077    <primary>pg_statistic</primary>
4078   </indexterm>
4079
4080   <para>
4081    The catalog <structname>pg_statistic</structname> stores
4082    statistical data about the contents of the database.  Entries are
4083    created by <xref linkend="sql-analyze" endterm="sql-analyze-title">
4084    and subsequently used by the query planner.  There is one entry for
4085    each table column that has been analyzed.  Note that all the
4086    statistical data is inherently approximate, even assuming that it
4087    is up-to-date.
4088   </para>
4089
4090   <para>
4091    <structname>pg_statistic</structname> also stores statistical data about
4092    the values of index expressions.  These are described as if they were
4093    actual data columns; in particular, <structfield>starelid</structfield>
4094    references the index.  No entry is made for an ordinary non-expression
4095    index column, however, since it would be redundant with the entry
4096    for the underlying table column.
4097   </para>
4098
4099   <para>
4100    Since different kinds of statistics might be appropriate for different
4101    kinds of data, <structname>pg_statistic</structname> is designed not
4102    to assume very much about what sort of statistics it stores.  Only
4103    extremely general statistics (such as nullness) are given dedicated
4104    columns in <structname>pg_statistic</structname>.  Everything else
4105    is stored in <quote>slots</quote>, which are groups of associated columns
4106    whose content is identified by a code number in one of the slot's columns.
4107    For more information see
4108    <filename>src/include/catalog/pg_statistic.h</filename>.
4109   </para>
4110
4111   <para>
4112    <structname>pg_statistic</structname> should not be readable by the
4113    public, since even statistical information about a table's contents
4114    might be considered sensitive.  (Example: minimum and maximum values
4115    of a salary column might be quite interesting.)
4116    <link linkend="view-pg-stats"><structname>pg_stats</structname></link>
4117    is a publicly readable view on
4118    <structname>pg_statistic</structname> that only exposes information
4119    about those tables that are readable by the current user.
4120   </para>
4121
4122   <table>
4123    <title><structname>pg_statistic</> Columns</title>
4124
4125    <tgroup cols=4>
4126     <thead>
4127      <row>
4128       <entry>Name</entry>
4129       <entry>Type</entry>
4130       <entry>References</entry>
4131       <entry>Description</entry>
4132      </row>
4133     </thead>
4134
4135     <tbody>
4136      <row>
4137       <entry><structfield>starelid</structfield></entry>
4138       <entry><type>oid</type></entry>
4139       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4140       <entry>The table or index that the described column belongs to</entry>
4141      </row>
4142
4143      <row>
4144       <entry><structfield>staattnum</structfield></entry>
4145       <entry><type>int2</type></entry>
4146       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
4147       <entry>The number of the described column</entry>
4148      </row>
4149
4150      <row>
4151       <entry><structfield>stanullfrac</structfield></entry>
4152       <entry><type>float4</type></entry>
4153       <entry></entry>
4154       <entry>The fraction of the column's entries that are null</entry>
4155      </row>
4156
4157      <row>
4158       <entry><structfield>stawidth</structfield></entry>
4159       <entry><type>int4</type></entry>
4160       <entry></entry>
4161       <entry>The average stored width, in bytes, of nonnull entries</entry>
4162      </row>
4163
4164      <row>
4165       <entry><structfield>stadistinct</structfield></entry>
4166       <entry><type>float4</type></entry>
4167       <entry></entry>
4168       <entry>The number of distinct nonnull data values in the column.
4169       A value greater than zero is the actual number of distinct values.
4170       A value less than zero is the negative of a fraction of the number
4171       of rows in the table (for example, a column in which values appear about
4172       twice on the average could be represented by <structfield>stadistinct</> = -0.5).
4173       A zero value means the number of distinct values is unknown
4174       </entry>
4175      </row>
4176
4177      <row>
4178       <entry><structfield>stakind<replaceable>N</></structfield></entry>
4179       <entry><type>int2</type></entry>
4180       <entry></entry>
4181       <entry>
4182        A code number indicating the kind of statistics stored in the
4183        <replaceable>N</>th <quote>slot</quote> of the
4184        <structname>pg_statistic</structname> row
4185       </entry>
4186      </row>
4187
4188      <row>
4189       <entry><structfield>staop<replaceable>N</></structfield></entry>
4190       <entry><type>oid</type></entry>
4191       <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
4192       <entry>
4193        An operator used to derive the statistics stored in the
4194        <replaceable>N</>th <quote>slot</quote>.  For example, a
4195        histogram slot would show the <literal>&lt;</literal> operator
4196        that defines the sort order of the data
4197       </entry>
4198      </row>
4199
4200      <row>
4201       <entry><structfield>stanumbers<replaceable>N</></structfield></entry>
4202       <entry><type>float4[]</type></entry>
4203       <entry></entry>
4204       <entry>
4205        Numerical statistics of the appropriate kind for the
4206        <replaceable>N</>th <quote>slot</quote>, or NULL if the slot
4207        kind does not involve numerical values
4208       </entry>
4209      </row>
4210
4211      <row>
4212       <entry><structfield>stavalues<replaceable>N</></structfield></entry>
4213       <entry><type>anyarray</type></entry>
4214       <entry></entry>
4215       <entry>
4216        Column data values of the appropriate kind for the
4217        <replaceable>N</>th <quote>slot</quote>, or NULL if the slot
4218        kind does not store any data values.  Each array's element
4219        values are actually of the specific column's data type, so there
4220        is no way to define these columns' type more specifically than
4221        <type>anyarray</>
4222       </entry>
4223      </row>
4224     </tbody>
4225    </tgroup>
4226   </table>
4227
4228  </sect1>
4229
4230
4231  <sect1 id="catalog-pg-tablespace">
4232   <title><structname>pg_tablespace</structname></title>
4233
4234   <indexterm zone="catalog-pg-tablespace">
4235    <primary>pg_tablespace</primary>
4236   </indexterm>
4237
4238   <para>
4239    The catalog <structname>pg_tablespace</structname> stores information
4240    about the available tablespaces.  Tables can be placed in particular
4241    tablespaces to aid administration of disk layout.
4242   </para>
4243
4244   <para>
4245    Unlike most system catalogs, <structname>pg_tablespace</structname>
4246    is shared across all databases of a cluster: there is only one
4247    copy of <structname>pg_tablespace</structname> per cluster, not
4248    one per database.
4249   </para>
4250
4251   <table>
4252    <title><structname>pg_tablespace</> Columns</title>
4253
4254    <tgroup cols=4>
4255     <thead>
4256      <row>
4257       <entry>Name</entry>
4258       <entry>Type</entry>
4259       <entry>References</entry>
4260       <entry>Description</entry>
4261      </row>
4262     </thead>
4263
4264     <tbody>
4265      <row>
4266       <entry><structfield>spcname</structfield></entry>
4267       <entry><type>name</type></entry>
4268       <entry></entry>
4269       <entry>Tablespace name</entry>
4270      </row>
4271
4272      <row>
4273       <entry><structfield>spcowner</structfield></entry>
4274       <entry><type>oid</type></entry>
4275       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4276       <entry>Owner of the tablespace, usually the user who created it</entry>
4277      </row>
4278
4279      <row>
4280       <entry><structfield>spclocation</structfield></entry>
4281       <entry><type>text</type></entry>
4282       <entry></entry>
4283       <entry>Location (directory path) of the tablespace</entry>
4284      </row>
4285
4286      <row>
4287       <entry><structfield>spcacl</structfield></entry>
4288       <entry><type>aclitem[]</type></entry>
4289       <entry></entry>
4290       <entry>
4291        Access privileges; see
4292        <xref linkend="sql-grant" endterm="sql-grant-title"> and
4293        <xref linkend="sql-revoke" endterm="sql-revoke-title">
4294        for details
4295       </entry>
4296      </row>
4297     </tbody>
4298    </tgroup>
4299   </table>
4300  </sect1>
4301
4302
4303  <sect1 id="catalog-pg-trigger">
4304   <title><structname>pg_trigger</structname></title>
4305
4306   <indexterm zone="catalog-pg-trigger">
4307    <primary>pg_trigger</primary>
4308   </indexterm>
4309
4310   <para>
4311    The catalog <structname>pg_trigger</structname> stores triggers on tables.
4312    See <xref linkend="sql-createtrigger" endterm="sql-createtrigger-title">
4313    for more information.
4314   </para>
4315
4316   <table>
4317    <title><structname>pg_trigger</> Columns</title>
4318
4319    <tgroup cols=4>
4320     <thead>
4321      <row>
4322       <entry>Name</entry>
4323       <entry>Type</entry>
4324       <entry>References</entry>
4325       <entry>Description</entry>
4326      </row>
4327     </thead>
4328
4329     <tbody>
4330      <row>
4331       <entry><structfield>tgrelid</structfield></entry>
4332       <entry><type>oid</type></entry>
4333       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4334       <entry>The table this trigger is on</entry>
4335      </row>
4336
4337      <row>
4338       <entry><structfield>tgname</structfield></entry>
4339       <entry><type>name</type></entry>
4340       <entry></entry>
4341       <entry>Trigger name (must be unique among triggers of same table)</entry>
4342      </row>
4343
4344      <row>
4345       <entry><structfield>tgfoid</structfield></entry>
4346       <entry><type>oid</type></entry>
4347       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4348       <entry>The function to be called</entry>
4349      </row>
4350
4351      <row>
4352       <entry><structfield>tgtype</structfield></entry>
4353       <entry><type>int2</type></entry>
4354       <entry></entry>
4355       <entry>Bit mask identifying trigger conditions</entry>
4356      </row>
4357
4358      <row>
4359       <entry><structfield>tgenabled</structfield></entry>
4360       <entry><type>char</type></entry>
4361       <entry></entry>
4362       <entry>
4363        Controls in which <xref linkend="guc-session-replication-role"> modes
4364        the trigger fires.
4365        <literal>O</> = trigger fires in <quote>origin</> and <quote>local</> modes,
4366        <literal>D</> = trigger is disabled,
4367        <literal>R</> = trigger fires in <quote>replica</> mode,
4368        <literal>A</> = trigger fires always.
4369       </entry>
4370      </row>
4371
4372      <row>
4373       <entry><structfield>tgisconstraint</structfield></entry>
4374       <entry><type>bool</type></entry>
4375       <entry></entry>
4376       <entry>True if trigger is a <quote>constraint trigger</></entry>
4377      </row>
4378
4379      <row>
4380       <entry><structfield>tgconstrname</structfield></entry>
4381       <entry><type>name</type></entry>
4382       <entry></entry>
4383       <entry>Constraint name, if a constraint trigger</entry>
4384      </row>
4385
4386      <row>
4387       <entry><structfield>tgconstrrelid</structfield></entry>
4388       <entry><type>oid</type></entry>
4389       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4390       <entry>The table referenced by a referential integrity constraint</entry>
4391      </row>
4392
4393      <row>
4394       <entry><structfield>tgconstraint</structfield></entry>
4395       <entry><type>oid</type></entry>
4396       <entry><literal><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link>.oid</literal></entry>
4397       <entry>The <structname>pg_constraint</> entry owning the trigger, if any</entry>
4398      </row>
4399
4400      <row>
4401       <entry><structfield>tgdeferrable</structfield></entry>
4402       <entry><type>bool</type></entry>
4403       <entry></entry>
4404       <entry>True if constraint trigger is deferrable</entry>
4405      </row>
4406
4407      <row>
4408       <entry><structfield>tginitdeferred</structfield></entry>
4409       <entry><type>bool</type></entry>
4410       <entry></entry>
4411       <entry>True if constraint trigger is initially deferred</entry>
4412      </row>
4413
4414      <row>
4415       <entry><structfield>tgnargs</structfield></entry>
4416       <entry><type>int2</type></entry>
4417       <entry></entry>
4418       <entry>Number of argument strings passed to trigger function</entry>
4419      </row>
4420
4421      <row>
4422       <entry><structfield>tgattr</structfield></entry>
4423       <entry><type>int2vector</type></entry>
4424       <entry></entry>
4425       <entry>Currently unused</entry>
4426      </row>
4427
4428      <row>
4429       <entry><structfield>tgargs</structfield></entry>
4430       <entry><type>bytea</type></entry>
4431       <entry></entry>
4432       <entry>Argument strings to pass to trigger, each NULL-terminated</entry>
4433      </row>
4434     </tbody>
4435    </tgroup>
4436   </table>
4437
4438   <note>
4439    <para>
4440     When <structfield>tgconstraint</> is nonzero,
4441     <structfield>tgisconstraint</> must be true, and
4442     <structfield>tgconstrname</>, <structfield>tgconstrrelid</>,
4443     <structfield>tgdeferrable</>, <structfield>tginitdeferred</> are redundant
4444     with the referenced <structname>pg_constraint</> entry.  The reason we
4445     keep these fields is that we support <quote>stand-alone</> constraint
4446     triggers with no corresponding <structname>pg_constraint</> entry.
4447    </para>
4448   </note>
4449
4450   <note>
4451    <para>
4452     <literal>pg_class.reltriggers</literal> needs to agree with the
4453     number of triggers found in this table for each relation.
4454    </para>
4455   </note>
4456
4457  </sect1>
4458
4459
4460  <sect1 id="catalog-pg-ts-config">
4461   <title><structname>pg_ts_config</structname></title>
4462
4463   <indexterm zone="catalog-pg-ts-config">
4464    <primary>pg_ts_config</primary>
4465   </indexterm>
4466
4467   <para>
4468    The <structname>pg_ts_config</structname> catalog contains entries
4469    representing text search configurations.  A configuration specifies
4470    a particular text search parser and a list of dictionaries to use
4471    for each of the parser's output token types.  The parser is shown
4472    in the <structname>pg_ts_config</structname> entry, but the
4473    token-to-dictionary mapping is defined by subsidiary entries in <link
4474    linkend="catalog-pg-ts-config-map"><structname>pg_ts_config_map</structname></link>.
4475   </para>
4476
4477   <para>
4478    <productname>PostgreSQL</productname>'s text search features are
4479    described at length in <xref linkend="textsearch">.
4480   </para>
4481
4482   <table>
4483    <title><structname>pg_ts_config</> Columns</title>
4484
4485    <tgroup cols=4>
4486     <thead>
4487      <row>
4488       <entry>Name</entry>
4489       <entry>Type</entry>
4490       <entry>References</entry>
4491       <entry>Description</entry>
4492      </row>
4493     </thead>
4494
4495     <tbody>
4496      <row>
4497       <entry><structfield>cfgname</structfield></entry>
4498       <entry><type>name</type></entry>
4499       <entry></entry>
4500       <entry>Text search configuration name</entry>
4501      </row>
4502
4503      <row>
4504       <entry><structfield>cfgnamespace</structfield></entry>
4505       <entry><type>oid</type></entry>
4506       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4507       <entry>
4508        The OID of the namespace that contains this configuration
4509       </entry>
4510      </row>
4511
4512      <row>
4513       <entry><structfield>cfgowner</structfield></entry>
4514       <entry><type>oid</type></entry>
4515       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4516       <entry>Owner of the configuration</entry>
4517      </row>
4518
4519      <row>
4520       <entry><structfield>cfgparser</structfield></entry>
4521       <entry><type>oid</type></entry>
4522       <entry><literal><link linkend="catalog-pg-ts-parser"><structname>pg_ts_parser</structname></link>.oid</literal></entry>
4523       <entry>The OID of the text search parser for this configuration</entry>
4524      </row>
4525     </tbody>
4526    </tgroup>
4527   </table>
4528  </sect1>
4529
4530
4531  <sect1 id="catalog-pg-ts-config-map">
4532   <title><structname>pg_ts_config_map</structname></title>
4533
4534   <indexterm zone="catalog-pg-ts-config-map">
4535    <primary>pg_ts_config_map</primary>
4536   </indexterm>
4537
4538   <para>
4539    The <structname>pg_ts_config_map</structname> catalog contains entries
4540    showing which text search dictionaries should be consulted, and in
4541    what order, for each output token type of each text search configuration's
4542    parser.
4543   </para>
4544
4545   <para>
4546    <productname>PostgreSQL</productname>'s text search features are
4547    described at length in <xref linkend="textsearch">.
4548   </para>
4549
4550   <table>
4551    <title><structname>pg_ts_config_map</> Columns</title>
4552
4553    <tgroup cols=4>
4554     <thead>
4555      <row>
4556       <entry>Name</entry>
4557       <entry>Type</entry>
4558       <entry>References</entry>
4559       <entry>Description</entry>
4560      </row>
4561     </thead>
4562
4563     <tbody>
4564      <row>
4565       <entry><structfield>mapcfg</structfield></entry>
4566       <entry><type>oid</type></entry>
4567       <entry><literal><link linkend="catalog-pg-ts-config"><structname>pg_ts_config</structname></link>.oid</literal></entry>
4568       <entry>The OID of the <structname>pg_ts_config</> entry owning this map entry</entry>
4569      </row>
4570
4571      <row>
4572       <entry><structfield>maptokentype</structfield></entry>
4573       <entry><type>integer</type></entry>
4574       <entry></entry>
4575       <entry>A token type emitted by the configuration's parser</entry>
4576      </row>
4577
4578      <row>
4579       <entry><structfield>mapseqno</structfield></entry>
4580       <entry><type>integer</type></entry>
4581       <entry></entry>
4582       <entry>Order in which to consult this entry (lower
4583        <structfield>mapseqno</>s first)</entry>
4584      </row>
4585
4586      <row>
4587       <entry><structfield>mapdict</structfield></entry>
4588       <entry><type>oid</type></entry>
4589       <entry><literal><link linkend="catalog-pg-ts-dict"><structname>pg_ts_dict</structname></link>.oid</literal></entry>
4590       <entry>The OID of the text search dictionary to consult</entry>
4591      </row>
4592     </tbody>
4593    </tgroup>
4594   </table>
4595  </sect1>
4596
4597
4598  <sect1 id="catalog-pg-ts-dict">
4599   <title><structname>pg_ts_dict</structname></title>
4600
4601   <indexterm zone="catalog-pg-ts-dict">
4602    <primary>pg_ts_dict</primary>
4603   </indexterm>
4604
4605   <para>
4606    The <structname>pg_ts_dict</structname> catalog contains entries
4607    defining text search dictionaries.  A dictionary depends on a text
4608    search template, which specifies all the implementation functions
4609    needed; the dictionary itself provides values for the user-settable
4610    parameters supported by the template.  This division of labor allows
4611    dictionaries to be created by unprivileged users.  The parameters
4612    are specified by a text string <structfield>dictinitoption</>,
4613    whose format and meaning vary depending on the template.
4614   </para>
4615
4616   <para>
4617    <productname>PostgreSQL</productname>'s text search features are
4618    described at length in <xref linkend="textsearch">.
4619   </para>
4620
4621   <table>
4622    <title><structname>pg_ts_dict</> Columns</title>
4623
4624    <tgroup cols=4>
4625     <thead>
4626      <row>
4627       <entry>Name</entry>
4628       <entry>Type</entry>
4629       <entry>References</entry>
4630       <entry>Description</entry>
4631      </row>
4632     </thead>
4633
4634     <tbody>
4635      <row>
4636       <entry><structfield>dictname</structfield></entry>
4637       <entry><type>name</type></entry>
4638       <entry></entry>
4639       <entry>Text search dictionary name</entry>
4640      </row>
4641
4642      <row>
4643       <entry><structfield>dictnamespace</structfield></entry>
4644       <entry><type>oid</type></entry>
4645       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4646       <entry>
4647        The OID of the namespace that contains this dictionary
4648       </entry>
4649      </row>
4650
4651      <row>
4652       <entry><structfield>dictowner</structfield></entry>
4653       <entry><type>oid</type></entry>
4654       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4655       <entry>Owner of the dictionary</entry>
4656      </row>
4657
4658      <row>
4659       <entry><structfield>dicttemplate</structfield></entry>
4660       <entry><type>oid</type></entry>
4661       <entry><literal><link linkend="catalog-pg-ts-template"><structname>pg_ts_template</structname></link>.oid</literal></entry>
4662       <entry>The OID of the text search template for this dictionary</entry>
4663      </row>
4664
4665      <row>
4666       <entry><structfield>dictinitoption</structfield></entry>
4667       <entry><type>text</type></entry>
4668       <entry></entry>
4669       <entry>Initialization option string for the template</entry>
4670      </row>
4671     </tbody>
4672    </tgroup>
4673   </table>
4674  </sect1>
4675
4676
4677  <sect1 id="catalog-pg-ts-parser">
4678   <title><structname>pg_ts_parser</structname></title>
4679
4680   <indexterm zone="catalog-pg-ts-parser">
4681    <primary>pg_ts_parser</primary>
4682   </indexterm>
4683
4684   <para>
4685    The <structname>pg_ts_parser</structname> catalog contains entries
4686    defining text search parsers.  A parser is responsible for splitting
4687    input text into lexemes and assigning a token type to each lexeme.
4688    Since a parser must be implemented by C-language-level functions,
4689    creation of new parsers is restricted to database superusers.
4690   </para>
4691
4692   <para>
4693    <productname>PostgreSQL</productname>'s text search features are
4694    described at length in <xref linkend="textsearch">.
4695   </para>
4696
4697   <table>
4698    <title><structname>pg_ts_parser</> Columns</title>
4699
4700    <tgroup cols=4>
4701     <thead>
4702      <row>
4703       <entry>Name</entry>
4704       <entry>Type</entry>
4705       <entry>References</entry>
4706       <entry>Description</entry>
4707      </row>
4708     </thead>
4709
4710     <tbody>
4711      <row>
4712       <entry><structfield>prsname</structfield></entry>
4713       <entry><type>name</type></entry>
4714       <entry></entry>
4715       <entry>Text search parser name</entry>
4716      </row>
4717
4718      <row>
4719       <entry><structfield>prsnamespace</structfield></entry>
4720       <entry><type>oid</type></entry>
4721       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4722       <entry>
4723        The OID of the namespace that contains this parser
4724       </entry>
4725      </row>
4726
4727      <row>
4728       <entry><structfield>prsstart</structfield></entry>
4729       <entry><type>regproc</type></entry>
4730       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4731       <entry>OID of the parser's startup function</entry>
4732      </row>
4733
4734      <row>
4735       <entry><structfield>prstoken</structfield></entry>
4736       <entry><type>regproc</type></entry>
4737       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4738       <entry>OID of the parser's next-token function</entry>
4739      </row>
4740
4741      <row>
4742       <entry><structfield>prsend</structfield></entry>
4743       <entry><type>regproc</type></entry>
4744       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4745       <entry>OID of the parser's shutdown function</entry>
4746      </row>
4747
4748      <row>
4749       <entry><structfield>prsheadline</structfield></entry>
4750       <entry><type>regproc</type></entry>
4751       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4752       <entry>OID of the parser's headline function</entry>
4753      </row>
4754
4755      <row>
4756       <entry><structfield>prslextype</structfield></entry>
4757       <entry><type>regproc</type></entry>
4758       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4759       <entry>OID of the parser's lextype function</entry>
4760      </row>
4761     </tbody>
4762    </tgroup>
4763   </table>
4764  </sect1>
4765
4766
4767  <sect1 id="catalog-pg-ts-template">
4768   <title><structname>pg_ts_template</structname></title>
4769
4770   <indexterm zone="catalog-pg-ts-template">
4771    <primary>pg_ts_template</primary>
4772   </indexterm>
4773
4774   <para>
4775    The <structname>pg_ts_template</structname> catalog contains entries
4776    defining text search templates.  A template is the implementation
4777    skeleton for a class of text search dictionaries.
4778    Since a template must be implemented by C-language-level functions,
4779    creation of new templates is restricted to database superusers.
4780   </para>
4781
4782   <para>
4783    <productname>PostgreSQL</productname>'s text search features are
4784    described at length in <xref linkend="textsearch">.
4785   </para>
4786
4787   <table>
4788    <title><structname>pg_ts_template</> Columns</title>
4789
4790    <tgroup cols=4>
4791     <thead>
4792      <row>
4793       <entry>Name</entry>
4794       <entry>Type</entry>
4795       <entry>References</entry>
4796       <entry>Description</entry>
4797      </row>
4798     </thead>
4799
4800     <tbody>
4801      <row>
4802       <entry><structfield>tmplname</structfield></entry>
4803       <entry><type>name</type></entry>
4804       <entry></entry>
4805       <entry>Text search template name</entry>
4806      </row>
4807
4808      <row>
4809       <entry><structfield>tmplnamespace</structfield></entry>
4810       <entry><type>oid</type></entry>
4811       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4812       <entry>
4813        The OID of the namespace that contains this template
4814       </entry>
4815      </row>
4816
4817      <row>
4818       <entry><structfield>tmplinit</structfield></entry>
4819       <entry><type>regproc</type></entry>
4820       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4821       <entry>OID of the template's initialization function</entry>
4822      </row>
4823
4824      <row>
4825       <entry><structfield>tmpllexize</structfield></entry>
4826       <entry><type>regproc</type></entry>
4827       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4828       <entry>OID of the template's lexize function</entry>
4829      </row>
4830     </tbody>
4831    </tgroup>
4832   </table>
4833  </sect1>
4834
4835
4836  <sect1 id="catalog-pg-type">
4837   <title><structname>pg_type</structname></title>
4838
4839   <indexterm zone="catalog-pg-type">
4840    <primary>pg_type</primary>
4841   </indexterm>
4842
4843   <para>
4844    The catalog <structname>pg_type</structname> stores information about data
4845    types.  Base types (scalar types) are created with
4846    <xref linkend="sql-createtype" endterm="sql-createtype-title">, and
4847    domains with
4848    <xref linkend="sql-createdomain" endterm="sql-createdomain-title">.
4849    A composite type is automatically created for each table in the database, to
4850    represent the row structure of the table.  It is also possible to create
4851    composite types with <command>CREATE TYPE AS</command>.
4852   </para>
4853
4854   <table>
4855    <title><structname>pg_type</> Columns</title>
4856
4857    <tgroup cols=4>
4858     <thead>
4859      <row>
4860       <entry>Name</entry>
4861       <entry>Type</entry>
4862       <entry>References</entry>
4863       <entry>Description</entry>
4864      </row>
4865     </thead>
4866
4867     <tbody>
4868      <row>
4869       <entry><structfield>typname</structfield></entry>
4870       <entry><type>name</type></entry>
4871       <entry></entry>
4872       <entry>Data type name</entry>
4873      </row>
4874
4875      <row>
4876       <entry><structfield>typnamespace</structfield></entry>
4877       <entry><type>oid</type></entry>
4878       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4879       <entry>
4880        The OID of the namespace that contains this type
4881       </entry>
4882      </row>
4883
4884      <row>
4885       <entry><structfield>typowner</structfield></entry>
4886       <entry><type>oid</type></entry>
4887       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4888       <entry>Owner of the type</entry>
4889      </row>
4890
4891      <row>
4892       <entry><structfield>typlen</structfield></entry>
4893       <entry><type>int2</type></entry>
4894       <entry></entry>
4895       <entry>
4896        For a fixed-size type, <structfield>typlen</structfield> is the number
4897        of bytes in the internal representation of the type.  But for a
4898        variable-length type, <structfield>typlen</structfield> is negative.
4899        -1 indicates a <quote>varlena</> type (one that has a length word),
4900        -2 indicates a null-terminated C string.
4901       </entry>
4902      </row>
4903
4904      <row>
4905       <entry><structfield>typbyval</structfield></entry>
4906       <entry><type>bool</type></entry>
4907       <entry></entry>
4908       <entry>
4909        <structfield>typbyval</structfield> determines whether internal
4910        routines pass a value of this type by value or by reference.
4911        <structfield>typbyval</structfield> had better be false if
4912        <structfield>typlen</structfield> is not 1, 2, or 4 (or 8 on machines
4913        where Datum is 8 bytes).
4914        Variable-length types are always passed by reference. Note that
4915        <structfield>typbyval</structfield> can be false even if the
4916        length would allow pass-by-value; this is currently true for
4917        type <type>float4</type>, for example
4918       </entry>
4919      </row>
4920
4921      <row>
4922       <entry><structfield>typtype</structfield></entry>
4923       <entry><type>char</type></entry>
4924       <entry></entry>
4925       <entry>
4926        <structfield>typtype</structfield> is
4927        <literal>b</literal> for a base type,
4928        <literal>c</literal> for a composite type (e.g., a table's row type),
4929        <literal>d</literal> for a domain,
4930        <literal>e</literal> for an enum type,
4931        or <literal>p</literal> for a pseudo-type.
4932        See also <structfield>typrelid</structfield> and
4933        <structfield>typbasetype</structfield>
4934       </entry>
4935      </row>
4936
4937      <row>
4938       <entry><structfield>typisdefined</structfield></entry>
4939       <entry><type>bool</type></entry>
4940       <entry></entry>
4941       <entry>
4942        True if the type is defined, false if this is a placeholder
4943        entry for a not-yet-defined type.  When
4944        <structfield>typisdefined</structfield> is false, nothing
4945        except the type name, namespace, and OID can be relied on
4946       </entry>
4947      </row>
4948
4949      <row>
4950       <entry><structfield>typdelim</structfield></entry>
4951       <entry><type>char</type></entry>
4952       <entry></entry>
4953       <entry>
4954        Character that separates two values of this type when parsing
4955        array input.  Note that the delimiter is associated with the array
4956        element data type, not the array data type
4957       </entry>
4958      </row>
4959
4960      <row>
4961       <entry><structfield>typrelid</structfield></entry>
4962       <entry><type>oid</type></entry>
4963       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4964       <entry>
4965        If this is a composite type (see
4966        <structfield>typtype</structfield>), then this column points to
4967        the <structname>pg_class</structname> entry that defines the
4968        corresponding table.  (For a free-standing composite type, the
4969        <structname>pg_class</structname> entry doesn't really represent
4970        a table, but it is needed anyway for the type's
4971        <structname>pg_attribute</structname> entries to link to.)
4972        Zero for non-composite types
4973       </entry>
4974      </row>
4975
4976      <row>
4977       <entry><structfield>typelem</structfield></entry>
4978       <entry><type>oid</type></entry>
4979       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
4980       <entry>
4981        If <structfield>typelem</structfield> is not 0 then it
4982        identifies another row in <structname>pg_type</structname>.
4983        The current type can then be subscripted like an array yielding
4984        values of type <structfield>typelem</structfield>.  A
4985        <quote>true</quote> array type is variable length
4986        (<structfield>typlen</structfield> = -1),
4987        but some fixed-length (<structfield>typlen</structfield> &gt; 0) types
4988        also have nonzero <structfield>typelem</structfield>, for example
4989        <type>name</type> and <type>point</type>.
4990        If a fixed-length type has a <structfield>typelem</structfield> then
4991        its internal representation must be some number of values of the
4992        <structfield>typelem</structfield> data type with no other data.
4993        Variable-length array types have a header defined by the array
4994        subroutines
4995       </entry>
4996      </row>
4997
4998      <row>
4999       <entry><structfield>typarray</structfield></entry>
5000       <entry><type>oid</type></entry>
5001       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
5002       <entry>
5003        If <structfield>typarray</structfield> is not 0 then it
5004        identifies another row in <structname>pg_type</structname>, which
5005        is the <quote>true</quote> array type having this type as element
5006       </entry>
5007      </row>
5008
5009      <row>
5010       <entry><structfield>typinput</structfield></entry>
5011       <entry><type>regproc</type></entry>
5012       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5013       <entry>Input conversion function (text format)</entry>
5014      </row>
5015
5016      <row>
5017       <entry><structfield>typoutput</structfield></entry>
5018       <entry><type>regproc</type></entry>
5019       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5020       <entry>Output conversion function (text format)</entry>
5021      </row>
5022
5023      <row>
5024       <entry><structfield>typreceive</structfield></entry>
5025       <entry><type>regproc</type></entry>
5026       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5027       <entry>Input conversion function (binary format), or 0 if none</entry>
5028      </row>
5029
5030      <row>
5031       <entry><structfield>typsend</structfield></entry>
5032       <entry><type>regproc</type></entry>
5033       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5034       <entry>Output conversion function (binary format), or 0 if none</entry>
5035      </row>
5036
5037      <row>
5038       <entry><structfield>typmodin</structfield></entry>
5039       <entry><type>regproc</type></entry>
5040       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5041       <entry>Type modifier input function, or 0 if type does not support modifiers</entry>
5042      </row>
5043
5044      <row>
5045       <entry><structfield>typmodout</structfield></entry>
5046       <entry><type>regproc</type></entry>
5047       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5048       <entry>Type modifier output function, or 0 to use the standard format</entry>
5049      </row>
5050
5051      <row>
5052       <entry><structfield>typanalyze</structfield></entry>
5053       <entry><type>regproc</type></entry>
5054       <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
5055       <entry>Custom ANALYZE function, or 0 to use the standard function</entry>
5056      </row>
5057
5058      <row>
5059       <entry><structfield>typalign</structfield></entry>
5060       <entry><type>char</type></entry>
5061       <entry></entry>
5062       <entry><para>
5063
5064        <structfield>typalign</structfield> is the alignment required
5065        when storing a value of this type.  It applies to storage on
5066        disk as well as most representations of the value inside
5067        <productname>PostgreSQL</>.
5068        When multiple values are stored consecutively, such
5069        as in the representation of a complete row on disk, padding is
5070        inserted before a datum of this type so that it begins on the
5071        specified boundary.  The alignment reference is the beginning
5072        of the first datum in the sequence.
5073       </para><para>
5074        Possible values are:
5075        <itemizedlist>
5076         <listitem>
5077          <para><literal>c</> = <type>char</type> alignment, i.e., no alignment needed.</para>
5078         </listitem>
5079         <listitem>
5080          <para><literal>s</> = <type>short</type> alignment (2 bytes on most machines).</para>
5081         </listitem>
5082         <listitem>
5083          <para><literal>i</> = <type>int</type> alignment (4 bytes on most machines).</para>
5084         </listitem>
5085         <listitem>
5086          <para><literal>d</> = <type>double</type> alignment (8 bytes on many machines, but by no means all).</para>
5087         </listitem>
5088        </itemizedlist>
5089       </para><note>
5090        <para>
5091         For types used in system tables, it is critical that the size
5092         and alignment defined in <structname>pg_type</structname>
5093         agree with the way that the compiler will lay out the column in
5094         a structure representing a table row.
5095        </para>
5096       </note></entry>
5097      </row>
5098
5099      <row>
5100       <entry><structfield>typstorage</structfield></entry>
5101       <entry><type>char</type></entry>
5102       <entry></entry>
5103       <entry><para>
5104        <structfield>typstorage</structfield> tells for varlena
5105        types (those with <structfield>typlen</structfield> = -1) if
5106        the type is prepared for toasting and what the default strategy
5107        for attributes of this type should be.
5108        Possible values are
5109        <itemizedlist>
5110         <listitem>
5111          <para><literal>p</>: Value must always be stored plain.</para>
5112         </listitem>
5113         <listitem>
5114          <para>
5115           <literal>e</>: Value can be stored in a <quote>secondary</quote>
5116           relation (if relation has one, see
5117           <literal>pg_class.reltoastrelid</literal>).
5118          </para>
5119         </listitem>
5120         <listitem>
5121          <para><literal>m</>: Value can be stored compressed inline.</para>
5122         </listitem>
5123         <listitem>
5124          <para><literal>x</>: Value can be stored compressed inline or stored in <quote>secondary</quote> storage.</para>
5125         </listitem>
5126        </itemizedlist>
5127        Note that <literal>m</> columns can also be moved out to secondary
5128        storage, but only as a last resort (<literal>e</> and <literal>x</> columns are
5129        moved first).
5130       </para></entry>
5131      </row>
5132
5133      <row>
5134       <entry><structfield>typnotnull</structfield></entry>
5135       <entry><type>bool</type></entry>
5136       <entry></entry>
5137       <entry><para>
5138        <structfield>typnotnull</structfield> represents a not-null
5139        constraint on a type.  Used for domains only
5140       </para></entry>
5141      </row>
5142
5143      <row>
5144       <entry><structfield>typbasetype</structfield></entry>
5145       <entry><type>oid</type></entry>
5146       <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
5147       <entry><para>
5148        If this is a domain (see <structfield>typtype</structfield>), then
5149        <structfield>typbasetype</structfield> identifies the type that this
5150        one is based on.  Zero if this type is not a domain
5151       </para></entry>
5152      </row>
5153
5154      <row>
5155       <entry><structfield>typtypmod</structfield></entry>
5156       <entry><type>int4</type></entry>
5157       <entry></entry>
5158       <entry><para>
5159        Domains use <structfield>typtypmod</structfield> to record the <literal>typmod</>
5160        to be applied to their base type (-1 if base type does not use a
5161        <literal>typmod</>).  -1 if this type is not a domain
5162       </para></entry>
5163      </row>
5164
5165      <row>
5166       <entry><structfield>typndims</structfield></entry>
5167       <entry><type>int4</type></entry>
5168       <entry></entry>
5169       <entry><para>
5170        <structfield>typndims</structfield> is the number of array dimensions
5171        for a domain that is an array (that is, <structfield>typbasetype</> is
5172        an array type; the domain's <structfield>typelem</> will match the base
5173        type's <structfield>typelem</structfield>).
5174        Zero for types other than domains over array types
5175        </para></entry>
5176      </row>
5177
5178      <row>
5179       <entry><structfield>typdefaultbin</structfield></entry>
5180       <entry><type>text</type></entry>
5181       <entry></entry>
5182       <entry><para>
5183        If <structfield>typdefaultbin</> is not null, it is the <function>nodeToString()</function>
5184        representation of a default expression for the type.  This is
5185        only used for domains
5186       </para></entry>
5187      </row>
5188
5189      <row>
5190       <entry><structfield>typdefault</structfield></entry>
5191       <entry><type>text</type></entry>
5192       <entry></entry>
5193       <entry><para>
5194        <structfield>typdefault</> is null if the type has no associated
5195        default value. If <structfield>typdefaultbin</> is not null,
5196        <structfield>typdefault</> must contain a human-readable version of the
5197        default expression represented by <structfield>typdefaultbin</>.  If
5198        <structfield>typdefaultbin</> is null and <structfield>typdefault</> is
5199        not, then <structfield>typdefault</> is the external representation of
5200        the type's default value, which might be fed to the type's input
5201        converter to produce a constant
5202       </para></entry>
5203      </row>
5204     </tbody>
5205    </tgroup>
5206   </table>
5207  </sect1>
5208
5209  <sect1 id="views-overview">
5210   <title>System Views</title>
5211
5212   <para>
5213    In addition to the system catalogs, <productname>PostgreSQL</productname>
5214    provides a number of built-in views.  Some system views provide convenient
5215    access to some commonly used queries on the system catalogs.  Other views
5216    provide access to internal server state.
5217   </para>
5218
5219   <para>
5220    The information schema (<xref linkend="information-schema">) provides
5221    an alternative set of views which overlap the functionality of the system
5222    views.  Since the information schema is SQL-standard whereas the views
5223    described here are <productname>PostgreSQL</productname>-specific,
5224    it's usually better to use the information schema if it provides all
5225    the information you need.
5226   </para>
5227
5228   <para>
5229    <xref linkend="view-table"> lists the system views described here.
5230    More detailed documentation of each view follows below.
5231    There are some additional views that provide access to the results of
5232    the statistics collector; they are described in <xref
5233    linkend="monitoring-stats-views-table">.
5234   </para>
5235
5236   <para>
5237    Except where noted, all the views described here are read-only.
5238   </para>
5239
5240   <table id="view-table">
5241    <title>System Views</title>
5242
5243    <tgroup cols="2">
5244     <thead>
5245      <row>
5246       <entry>View Name</entry>
5247       <entry>Purpose</entry>
5248      </row>
5249     </thead>
5250
5251     <tbody>
5252      <row>
5253       <entry><link linkend="view-pg-cursors"><structname>pg_cursors</structname></link></entry>
5254       <entry>open cursors</entry>
5255      </row>
5256
5257      <row>
5258       <entry><link linkend="view-pg-group"><structname>pg_group</structname></link></entry>
5259       <entry>groups of database users</entry>
5260      </row>
5261
5262      <row>
5263       <entry><link linkend="view-pg-indexes"><structname>pg_indexes</structname></link></entry>
5264       <entry>indexes</entry>
5265      </row>
5266
5267      <row>
5268       <entry><link linkend="view-pg-locks"><structname>pg_locks</structname></link></entry>
5269       <entry>currently held locks</entry>
5270      </row>
5271
5272      <row>
5273       <entry><link linkend="view-pg-prepared-statements"><structname>pg_prepared_statements</structname></link></entry>
5274       <entry>prepared statements</entry>
5275      </row>
5276
5277      <row>
5278       <entry><link linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link></entry>
5279       <entry>prepared transactions</entry>
5280      </row>
5281
5282      <row>
5283       <entry><link linkend="view-pg-roles"><structname>pg_roles</structname></link></entry>
5284       <entry>database roles</entry>
5285      </row>
5286
5287      <row>
5288       <entry><link linkend="view-pg-rules"><structname>pg_rules</structname></link></entry>
5289       <entry>rules</entry>
5290      </row>
5291
5292      <row>
5293       <entry><link linkend="view-pg-settings"><structname>pg_settings</structname></link></entry>
5294       <entry>parameter settings</entry>
5295      </row>
5296
5297      <row>
5298       <entry><link linkend="view-pg-shadow"><structname>pg_shadow</structname></link></entry>
5299       <entry>database users</entry>
5300      </row>
5301
5302      <row>
5303       <entry><link linkend="view-pg-stats"><structname>pg_stats</structname></link></entry>
5304       <entry>planner statistics</entry>
5305      </row>
5306
5307      <row>
5308       <entry><link linkend="view-pg-tables"><structname>pg_tables</structname></link></entry>
5309       <entry>tables</entry>
5310      </row>
5311
5312      <row>
5313       <entry><link linkend="view-pg-timezone-abbrevs"><structname>pg_timezone_abbrevs</structname></link></entry>
5314       <entry>time zone abbreviations</entry>
5315      </row>
5316
5317      <row>
5318       <entry><link linkend="view-pg-timezone-names"><structname>pg_timezone_names</structname></link></entry>
5319       <entry>time zone names</entry>
5320      </row>
5321
5322      <row>
5323       <entry><link linkend="view-pg-user"><structname>pg_user</structname></link></entry>
5324       <entry>database users</entry>
5325      </row>
5326
5327      <row>
5328       <entry><link linkend="view-pg-views"><structname>pg_views</structname></link></entry>
5329       <entry>views</entry>
5330      </row>
5331
5332     </tbody>
5333    </tgroup>
5334   </table>
5335  </sect1>
5336
5337  <sect1 id="view-pg-cursors">
5338   <title><structname>pg_cursors</structname></title>
5339
5340   <indexterm zone="view-pg-cursors">
5341    <primary>pg_cursors</primary>
5342   </indexterm>
5343
5344   <para>
5345    The <structname>pg_cursors</structname> view lists the cursors that
5346    are currently available. Cursors can be defined in several ways:
5347    <itemizedlist>
5348     <listitem>
5349      <para>
5350       via the <xref linkend="sql-declare" endterm="sql-declare-title">
5351       statement in SQL
5352      </para>
5353     </listitem>
5354
5355     <listitem>
5356      <para>
5357       via the Bind message in the frontend/backend protocol, as
5358       described in <xref linkend="protocol-flow-ext-query">
5359      </para>
5360     </listitem>
5361
5362     <listitem>
5363      <para>
5364       via the Server Programming Interface (SPI), as described in
5365       <xref linkend="spi-interface">
5366      </para>
5367     </listitem>
5368    </itemizedlist>
5369
5370    The <structname>pg_cursors</structname> view displays cursors
5371    created by any of these means. Cursors only exist for the duration
5372    of the transaction that defines them, unless they have been
5373    declared <literal>WITH HOLD</literal>. Therefore non-holdable
5374    cursors are only present in the view until the end of their
5375    creating transaction.
5376
5377    <note>
5378     <para>
5379      Cursors are used internally to implement some of the components
5380      of <productname>PostgreSQL</>, such as procedural languages.
5381      Therefore, the <structname>pg_cursors</> view might include cursors
5382      that have not been explicitly created by the user.
5383     </para>
5384    </note>
5385   </para>
5386
5387   <table>
5388    <title><structname>pg_cursors</> Columns</title>
5389
5390    <tgroup cols=3>
5391     <thead>
5392      <row>
5393       <entry>Name</entry>
5394       <entry>Type</entry>
5395       <entry>Description</entry>
5396      </row>
5397     </thead>
5398
5399     <tbody>
5400      <row>
5401       <entry><structfield>name</structfield></entry>
5402       <entry><type>text</type></entry>
5403       <entry>The name of the cursor</entry>
5404      </row>
5405
5406      <row>
5407       <entry><structfield>statement</structfield></entry>
5408       <entry><type>text</type></entry>
5409       <entry>The verbatim query string submitted to declare this cursor</entry>
5410      </row>
5411
5412      <row>
5413       <entry><structfield>is_holdable</structfield></entry>
5414       <entry><type>boolean</type></entry>
5415       <entry>
5416        <literal>true</literal> if the cursor is holdable (that is, it
5417        can be accessed after the transaction that declared the cursor
5418        has committed); <literal>false</literal> otherwise
5419        </entry>
5420      </row>
5421
5422      <row>
5423       <entry><structfield>is_binary</structfield></entry>
5424       <entry><type>boolean</type></entry>
5425       <entry>
5426        <literal>true</literal> if the cursor was declared
5427        <literal>BINARY</literal>; <literal>false</literal>
5428        otherwise
5429        </entry>
5430      </row>
5431
5432      <row>
5433       <entry><structfield>is_scrollable</structfield></entry>
5434       <entry><type>boolean</type></entry>
5435       <entry>
5436        <literal>true</> if the cursor is scrollable (that is, it
5437        allows rows to be retrieved in a nonsequential manner);
5438        <literal>false</literal> otherwise
5439        </entry>
5440      </row>
5441
5442      <row>
5443       <entry><structfield>creation_time</structfield></entry>
5444       <entry><type>timestamptz</type></entry>
5445       <entry>The time at which the cursor was declared</entry>
5446      </row>
5447     </tbody>
5448    </tgroup>
5449   </table>
5450
5451   <para>
5452    The <structname>pg_cursors</structname> view is read only.
5453   </para>
5454
5455  </sect1>
5456
5457  <sect1 id="view-pg-group">
5458   <title><structname>pg_group</structname></title>
5459
5460   <indexterm zone="view-pg-group">
5461    <primary>pg_group</primary>
5462   </indexterm>
5463
5464   <para>
5465    The view <structname>pg_group</structname> exists for backwards
5466    compatibility: it emulates a catalog that existed in
5467    <productname>PostgreSQL</productname> before version 8.1.
5468    It shows the names and members of all roles that are marked as not
5469    <structfield>rolcanlogin</>, which is an approximation to the set
5470    of roles that are being used as groups.
5471   </para>
5472
5473   <table>
5474    <title><structname>pg_group</> Columns</title>
5475
5476    <tgroup cols=4>
5477     <thead>
5478      <row>
5479       <entry>Name</entry>
5480       <entry>Type</entry>
5481       <entry>References</entry>
5482       <entry>Description</entry>
5483      </row>
5484     </thead>
5485
5486     <tbody>
5487      <row>
5488       <entry><structfield>groname</structfield></entry>
5489       <entry><type>name</type></entry>
5490       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
5491       <entry>Name of the group</entry>
5492      </row>
5493
5494      <row>
5495       <entry><structfield>grosysid</structfield></entry>
5496       <entry><type>oid</type></entry>
5497       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
5498       <entry>ID of this group</entry>
5499      </row>
5500
5501      <row>
5502       <entry><structfield>grolist</structfield></entry>
5503       <entry><type>oid[]</type></entry>
5504       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
5505       <entry>An array containing the IDs of the roles in this group</entry>
5506      </row>
5507     </tbody>
5508    </tgroup>
5509   </table>
5510
5511  </sect1>
5512
5513  <sect1 id="view-pg-indexes">
5514   <title><structname>pg_indexes</structname></title>
5515
5516   <indexterm zone="view-pg-indexes">
5517    <primary>pg_indexes</primary>
5518   </indexterm>
5519
5520   <para>
5521    The view <structname>pg_indexes</structname> provides access to
5522    useful information about each index in the database.
5523   </para>
5524
5525   <table>
5526    <title><structname>pg_indexes</> Columns</title>
5527
5528    <tgroup cols=4>
5529     <thead>
5530      <row>
5531       <entry>Name</entry>
5532       <entry>Type</entry>
5533       <entry>References</entry>
5534       <entry>Description</entry>
5535      </row>
5536     </thead>
5537     <tbody>
5538      <row>
5539       <entry><structfield>schemaname</structfield></entry>
5540       <entry><type>name</type></entry>
5541       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
5542       <entry>Name of schema containing table and index</entry>
5543      </row>
5544      <row>
5545       <entry><structfield>tablename</structfield></entry>
5546       <entry><type>name</type></entry>
5547       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
5548       <entry>Name of table the index is for</entry>
5549      </row>
5550      <row>
5551       <entry><structfield>indexname</structfield></entry>
5552       <entry><type>name</type></entry>
5553       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
5554       <entry>Name of index</entry>
5555      </row>
5556      <row>
5557       <entry><structfield>tablespace</structfield></entry>
5558       <entry><type>name</type></entry>
5559       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.spcname</literal></entry>
5560       <entry>Name of tablespace containing index (NULL if default for database)</entry>
5561      </row>
5562      <row>
5563       <entry><structfield>indexdef</structfield></entry>
5564       <entry><type>text</type></entry>
5565       <entry></entry>
5566       <entry>Index definition (a reconstructed <command>CREATE INDEX</command>
5567       command)</entry>
5568      </row>
5569     </tbody>
5570    </tgroup>
5571   </table>
5572
5573  </sect1>
5574
5575  <sect1 id="view-pg-locks">
5576   <title><structname>pg_locks</structname></title>
5577
5578   <indexterm zone="view-pg-locks">
5579    <primary>pg_locks</primary>
5580   </indexterm>
5581
5582   <para>
5583    The view <structname>pg_locks</structname> provides access to
5584    information about the locks held by open transactions within the
5585    database server.  See <xref linkend="mvcc"> for more discussion
5586    of locking.
5587   </para>
5588
5589   <para>
5590    <structname>pg_locks</structname> contains one row per active lockable
5591    object, requested lock mode, and relevant transaction.  Thus, the same
5592    lockable object might
5593    appear many times, if multiple transactions are holding or waiting
5594    for locks on it.  However, an object that currently has no locks on it
5595    will not appear at all.
5596   </para>
5597
5598   <para>
5599    There are several distinct types of lockable objects:
5600    whole relations (e.g., tables), individual pages of relations,
5601    individual tuples of relations,
5602    transaction IDs (both virtual and permanent IDs),
5603    and general database objects (identified by class OID and object OID,
5604    in the same way as in <structname>pg_description</structname> or
5605    <structname>pg_depend</structname>).  Also, the right to extend a
5606    relation is represented as a separate lockable object.
5607   </para>
5608
5609   <table>
5610    <title><structname>pg_locks</> Columns</title>
5611
5612    <tgroup cols=4>
5613     <thead>
5614      <row>
5615       <entry>Name</entry>
5616       <entry>Type</entry>
5617       <entry>References</entry>
5618       <entry>Description</entry>
5619      </row>
5620     </thead>
5621     <tbody>
5622      <row>
5623       <entry><structfield>locktype</structfield></entry>
5624       <entry><type>text</type></entry>
5625       <entry></entry>
5626       <entry>
5627        type of the lockable object:
5628        <literal>relation</>,
5629        <literal>extend</>,
5630        <literal>page</>,
5631        <literal>tuple</>,
5632        <literal>transactionid</>,
5633        <literal>virtualxid</>,
5634        <literal>object</>,
5635        <literal>userlock</>, or
5636        <literal>advisory</>
5637       </entry>
5638      </row>
5639      <row>
5640       <entry><structfield>database</structfield></entry>
5641       <entry><type>oid</type></entry>
5642       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
5643       <entry>
5644        OID of the database in which the object exists, or
5645        zero if the object is a shared object, or
5646        NULL if the object is a transaction ID
5647       </entry>
5648      </row>
5649      <row>
5650       <entry><structfield>relation</structfield></entry>
5651       <entry><type>oid</type></entry>
5652       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
5653       <entry>
5654        OID of the relation, or NULL if the object is not
5655        a relation or part of a relation
5656       </entry>
5657      </row>
5658      <row>
5659       <entry><structfield>page</structfield></entry>
5660       <entry><type>integer</type></entry>
5661       <entry></entry>
5662       <entry>
5663        Page number within the relation, or NULL if the object
5664        is not a tuple or relation page
5665       </entry>
5666      </row>
5667      <row>
5668       <entry><structfield>tuple</structfield></entry>
5669       <entry><type>smallint</type></entry>
5670       <entry></entry>
5671       <entry>
5672        Tuple number within the page, or NULL if the object is not a tuple
5673       </entry>
5674      </row>
5675      <row>
5676       <entry><structfield>virtualxid</structfield></entry>
5677       <entry><type>text</type></entry>
5678       <entry></entry>
5679       <entry>
5680        Virtual ID of a transaction, or NULL if the object is not a
5681        virtual transaction ID
5682       </entry>
5683      </row>
5684      <row>
5685       <entry><structfield>transactionid</structfield></entry>
5686       <entry><type>xid</type></entry>
5687       <entry></entry>
5688       <entry>
5689        ID of a transaction, or NULL if the object is not a transaction ID
5690       </entry>
5691      </row>
5692      <row>
5693       <entry><structfield>classid</structfield></entry>
5694       <entry><type>oid</type></entry>
5695       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
5696       <entry>
5697        OID of the system catalog containing the object, or NULL if the
5698        object is not a general database object
5699       </entry>
5700      </row>
5701      <row>
5702       <entry><structfield>objid</structfield></entry>
5703       <entry><type>oid</type></entry>
5704       <entry>any OID column</entry>
5705       <entry>
5706        OID of the object within its system catalog, or NULL if the
5707        object is not a general database object.
5708        For advisory locks it is used to distinguish the two key
5709        spaces (<literal>1</> for an int8 key, <literal>2</> for two
5710        int4 keys).
5711       </entry>
5712      </row>
5713      <row>
5714       <entry><structfield>objsubid</structfield></entry>
5715       <entry><type>smallint</type></entry>
5716       <entry></entry>
5717       <entry>
5718        For a table column, this is the column number (the
5719        <structfield>classid</> and <structfield>objid</> refer to the
5720        table itself).  For all other object types, this column is
5721        zero.  NULL if the object is not a general database object
5722       </entry>
5723      </row>
5724      <row>
5725       <entry><structfield>virtualtransaction</structfield></entry>
5726       <entry><type>text</type></entry>
5727       <entry></entry>
5728       <entry>
5729        Virtual ID of the transaction that is holding or awaiting this lock
5730       </entry>
5731      </row>
5732      <row>
5733       <entry><structfield>pid</structfield></entry>
5734       <entry><type>integer</type></entry>
5735       <entry></entry>
5736       <entry>
5737        Process ID of the server process holding or awaiting this
5738        lock.  NULL if the lock is held by a prepared transaction
5739       </entry>
5740      </row>
5741      <row>
5742       <entry><structfield>mode</structfield></entry>
5743       <entry><type>text</type></entry>
5744       <entry></entry>
5745       <entry>Name of the lock mode held or desired by this process (see <xref
5746       linkend="locking-tables">)</entry>
5747      </row>
5748      <row>
5749       <entry><structfield>granted</structfield></entry>
5750       <entry><type>boolean</type></entry>
5751       <entry></entry>
5752       <entry>True if lock is held, false if lock is awaited</entry>
5753      </row>
5754     </tbody>
5755    </tgroup>
5756   </table>
5757
5758   <para>
5759    <structfield>granted</structfield> is true in a row representing a lock
5760    held by the indicated transaction.  False indicates that this transaction is
5761    currently waiting to acquire this lock, which implies that some other
5762    transaction is holding a conflicting lock mode on the same lockable object.
5763    The waiting transaction will sleep until the other lock is released (or a
5764    deadlock situation is detected). A single transaction can be waiting to
5765    acquire at most one lock at a time.
5766   </para>
5767
5768   <para>
5769    Every transaction holds an exclusive lock on its virtual transaction ID for
5770    its entire duration.  If a permanent ID is assigned to the transaction
5771    (which normally happens only if the transaction changes the state of the
5772    database), it also holds an exclusive lock on its permanent transaction ID
5773    until it ends.  When one transaction finds it necessary to wait specifically
5774    for another transaction, it does so by attempting to acquire share lock on
5775    the other transaction ID (either virtual or permanent ID depending on the
5776    situation). That will succeed only when the other transaction
5777    terminates and releases its locks. 
5778   </para>
5779
5780   <para>
5781    Although tuples are a lockable type of object,
5782    information about row-level locks is stored on disk, not in memory,
5783    and therefore row-level locks normally do not appear in this view.
5784    If a transaction is waiting for a
5785    row-level lock, it will usually appear in the view as waiting for the
5786    permanent transaction ID of the current holder of that row lock.
5787   </para>
5788
5789   <para>
5790    Advisory locks can be acquired on keys consisting of either a single
5791    <type>bigint</type> value or two integer values.  A <type>bigint</type> key is displayed with its
5792    high-order half in the <structfield>classid</> column, its low-order half
5793    in the <structfield>objid</> column, and <structfield>objsubid</> equal
5794    to 1.  Integer keys are displayed with the first key in the
5795    <structfield>classid</> column, the second key in the <structfield>objid</>
5796    column, and <structfield>objsubid</> equal to 2.  The actual meaning of
5797    the keys is up to the user.  Advisory locks are local to each database,
5798    so the <structfield>database</> column is meaningful for an advisory lock.
5799   </para>
5800
5801   <para>
5802    When the <structname>pg_locks</structname> view is accessed, the
5803    internal lock manager data structures are momentarily locked, and
5804    a copy is made for the view to display.  This ensures that the
5805    view produces a consistent set of results, while not blocking
5806    normal lock manager operations longer than necessary.  Nonetheless
5807    there could be some impact on database performance if this view is
5808    frequently accessed.
5809   </para>
5810
5811   <para>
5812    <structname>pg_locks</structname> provides a global view of all locks
5813    in the database cluster, not only those relevant to the current database.
5814    Although its <structfield>relation</structfield> column can be joined
5815    against <structname>pg_class</>.<structfield>oid</> to identify locked
5816    relations, this will only work correctly for relations in the current
5817    database (those for which the <structfield>database</structfield> column
5818    is either the current database's OID or zero).
5819   </para>
5820
5821   <para>
5822    The <structfield>pid</structfield> column can be joined to the
5823    <structfield>procpid</structfield> column of the
5824    <structname>pg_stat_activity</structname> view to get more
5825    information on the session holding or waiting to hold each lock.
5826    Also, if you are using prepared transactions, the
5827    <structfield>transaction</> column can be joined to the
5828    <structfield>transaction</structfield> column of the
5829    <structname>pg_prepared_xacts</structname> view to get more
5830    information on prepared transactions that hold locks.
5831    (A prepared transaction can never be waiting for a lock,
5832    but it continues to hold the locks it acquired while running.)
5833   </para>
5834
5835  </sect1>
5836
5837  <sect1 id="view-pg-prepared-statements">
5838   <title><structname>pg_prepared_statements</structname></title>
5839
5840   <indexterm zone="view-pg-prepared-statements">
5841    <primary>pg_prepared_statements</primary>
5842   </indexterm>
5843
5844   <para>
5845    The <structname>pg_prepared_statements</structname> view displays
5846    all the prepared statements that are available in the current
5847    session. See <xref linkend="sql-prepare"
5848    endterm="sql-prepare-title"> for more information about prepared
5849    statements.
5850   </para>
5851
5852   <para>
5853    <structname>pg_prepared_statements</structname> contains one row
5854    for each prepared statement. Rows are added to the view when a new
5855    prepared statement is created and removed when a prepared statement
5856    is released (for example, via the <xref linkend="sql-deallocate"
5857    endterm="sql-deallocate-title"> command).
5858   </para>
5859
5860   <table>
5861    <title><structname>pg_prepared_statements</> Columns</title>
5862
5863    <tgroup cols=3>
5864     <thead>
5865      <row>
5866       <entry>Name</entry>
5867       <entry>Type</entry>
5868       <entry>Description</entry>
5869      </row>
5870     </thead>
5871     <tbody>
5872      <row>
5873       <entry><structfield>name</structfield></entry>
5874       <entry><type>text</type></entry>
5875       <entry>
5876        The identifier of the prepared statement
5877       </entry>
5878      </row>
5879      <row>
5880       <entry><structfield>statement</structfield></entry>
5881       <entry><type>text</type></entry>
5882       <entry>
5883        The query string submitted by the client to create this
5884        prepared statement. For prepared statements created via SQL,
5885        this is the <command>PREPARE</command> statement submitted by
5886        the client. For prepared statements created via the
5887        frontend/backend protocol, this is the text of the prepared
5888        statement itself
5889       </entry>
5890      </row>
5891      <row>
5892       <entry><structfield>prepare_time</structfield></entry>
5893       <entry><type>timestamptz</type></entry>
5894       <entry>
5895        The time at which the prepared statement was created
5896       </entry>
5897      </row>
5898      <row>
5899       <entry><structfield>parameter_types</structfield></entry>
5900       <entry><type>regtype[]</type></entry>
5901       <entry>
5902        The expected parameter types for the prepared statement in the
5903        form of an array of <type>regtype</type>. The OID corresponding
5904        to an element of this array can be obtained by casting the
5905        <type>regtype</type> value to <type>oid</type>
5906       </entry>
5907      </row>
5908      <row>
5909       <entry><structfield>from_sql</structfield></entry>
5910       <entry><type>boolean</type></entry>
5911       <entry>
5912        <literal>true</literal> if the prepared statement was created
5913        via the <command>PREPARE</command> SQL statement;
5914        <literal>false</literal> if the statement was prepared via the
5915        frontend/backend protocol
5916       </entry>
5917      </row>
5918     </tbody>
5919    </tgroup>
5920   </table>
5921
5922   <para>
5923    The <structname>pg_prepared_statements</structname> view is read only.
5924   </para>
5925  </sect1>
5926
5927  <sect1 id="view-pg-prepared-xacts">
5928   <title><structname>pg_prepared_xacts</structname></title>
5929
5930   <indexterm zone="view-pg-prepared-xacts">
5931    <primary>pg_prepared_xacts</primary>
5932   </indexterm>
5933
5934   <para>
5935    The view <structname>pg_prepared_xacts</structname> displays
5936    information about transactions that are currently prepared for two-phase
5937    commit (see <xref linkend="sql-prepare-transaction"
5938    endterm="sql-prepare-transaction-title"> for details).
5939   </para>
5940
5941   <para>
5942    <structname>pg_prepared_xacts</structname> contains one row per prepared
5943    transaction.  An entry is removed when the transaction is committed or
5944    rolled back.
5945   </para>
5946
5947   <table>
5948    <title><structname>pg_prepared_xacts</> Columns</title>
5949
5950    <tgroup cols=4>
5951     <thead>
5952      <row>
5953       <entry>Name</entry>
5954       <entry>Type</entry>
5955       <entry>References</entry>
5956       <entry>Description</entry>
5957      </row>
5958     </thead>
5959     <tbody>
5960      <row>
5961       <entry><structfield>transaction</structfield></entry>
5962       <entry><type>xid</type></entry>
5963       <entry></entry>
5964       <entry>
5965        Numeric transaction identifier of the prepared transaction
5966       </entry>
5967      </row>
5968      <row>
5969       <entry><structfield>gid</structfield></entry>
5970       <entry><type>text</type></entry>
5971       <entry></entry>
5972       <entry>
5973        Global transaction identifier that was assigned to the transaction
5974       </entry>
5975      </row>
5976      <row>
5977       <entry><structfield>prepared</structfield></entry>
5978       <entry><type>timestamp with time zone</type></entry>
5979       <entry></entry>
5980       <entry>
5981        Time at which the transaction was prepared for commit
5982       </entry>
5983      </row>
5984      <row>
5985       <entry><structfield>owner</structfield></entry>
5986       <entry><type>name</type></entry>
5987       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
5988       <entry>
5989        Name of the user that executed the transaction
5990       </entry>
5991      </row>
5992      <row>
5993       <entry><structfield>database</structfield></entry>
5994       <entry><type>name</type></entry>
5995       <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.datname</literal></entry>
5996       <entry>
5997        Name of the database in which the transaction was executed
5998       </entry>
5999      </row>
6000     </tbody>
6001    </tgroup>
6002   </table>
6003
6004   <para>
6005    When the <structname>pg_prepared_xacts</structname> view is accessed, the
6006    internal transaction manager data structures are momentarily locked, and
6007    a copy is made for the view to display.  This ensures that the
6008    view produces a consistent set of results, while not blocking
6009    normal operations longer than necessary.  Nonetheless
6010    there could be some impact on database performance if this view is
6011    frequently accessed.
6012   </para>
6013
6014  </sect1>
6015
6016  <sect1 id="view-pg-roles">
6017   <title><structname>pg_roles</structname></title>
6018
6019   <indexterm zone="view-pg-roles">
6020    <primary>pg_roles</primary>
6021   </indexterm>
6022
6023   <para>
6024    The view <structname>pg_roles</structname> provides access to
6025    information about database roles.  This is simply a publicly
6026    readable view of 
6027    <link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>
6028    that blanks out the password field.
6029   </para>
6030
6031   <para>
6032    This view explicitly exposes the OID column of the underlying table,
6033    since that is needed to do joins to other catalogs.
6034   </para>
6035
6036   <table>
6037    <title><structname>pg_roles</> Columns</title>
6038
6039    <tgroup cols=4>
6040     <thead>
6041      <row>
6042       <entry>Name</entry>
6043       <entry>Type</entry>
6044       <entry>References</entry>
6045       <entry>Description</entry>
6046      </row>
6047     </thead>
6048
6049     <tbody>
6050      <row>
6051       <entry><structfield>rolname</structfield></entry>
6052       <entry><type>name</type></entry>
6053       <entry></entry>
6054       <entry>Role name</entry>
6055      </row>
6056
6057      <row>
6058       <entry><structfield>rolsuper</structfield></entry>
6059       <entry><type>bool</type></entry>
6060       <entry></entry>
6061       <entry>Role has superuser privileges</entry>
6062      </row>
6063
6064      <row>
6065       <entry><structfield>rolinherit</structfield></entry>
6066       <entry><type>bool</type></entry>
6067       <entry></entry>
6068       <entry>Role automatically inherits privileges of roles it is a
6069        member of</entry>
6070      </row>
6071
6072      <row>
6073       <entry><structfield>rolcreaterole</structfield></entry>
6074       <entry><type>bool</type></entry>
6075       <entry></entry>
6076       <entry>Role can create more roles</entry>
6077      </row>
6078
6079      <row>
6080       <entry><structfield>rolcreatedb</structfield></entry>
6081       <entry><type>bool</type></entry>
6082       <entry></entry>
6083       <entry>Role can create databases</entry>
6084      </row>
6085
6086      <row>
6087       <entry><structfield>rolcatupdate</structfield></entry>
6088       <entry><type>bool</type></entry>
6089       <entry></entry>
6090       <entry>
6091        Role can update system catalogs directly.  (Even a superuser cannot do
6092        this unless this column is true.)
6093       </entry>
6094      </row>
6095
6096      <row>
6097       <entry><structfield>rolcanlogin</structfield></entry>
6098       <entry><type>bool</type></entry>
6099       <entry></entry>
6100       <entry>
6101        Role can log in. That is, this role can be given as the initial
6102        session authorization identifier
6103       </entry>
6104      </row>
6105
6106      <row>
6107       <entry><structfield>rolconnlimit</structfield></entry>
6108       <entry><type>int4</type></entry>
6109       <entry></entry>
6110       <entry>
6111        For roles that can log in, this sets maximum number of concurrent 
6112        connections this role can make.  -1 means no limit
6113       </entry>
6114      </row>
6115
6116      <row>
6117       <entry><structfield>rolpassword</structfield></entry>
6118       <entry><type>text</type></entry>
6119       <entry></entry>
6120       <entry>Not the password (always reads as <literal>********</>)</entry>
6121      </row>
6122
6123      <row>
6124       <entry><structfield>rolvaliduntil</structfield></entry>
6125       <entry><type>timestamptz</type></entry>
6126       <entry></entry>
6127       <entry>Password expiry time (only used for password authentication);
6128        NULL if no expiration</entry>
6129      </row>
6130
6131      <row>
6132       <entry><structfield>rolconfig</structfield></entry>
6133       <entry><type>text[]</type></entry>
6134       <entry></entry>
6135       <entry>Session defaults for run-time configuration variables</entry>
6136      </row>
6137
6138      <row>
6139       <entry><structfield>oid</structfield></entry>
6140       <entry><type>oid</type></entry>
6141       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6142       <entry>ID of role</entry>
6143      </row>
6144     </tbody>
6145    </tgroup>
6146   </table>
6147
6148  </sect1>
6149
6150  <sect1 id="view-pg-rules">
6151   <title><structname>pg_rules</structname></title>
6152
6153   <indexterm zone="view-pg-rules">
6154    <primary>pg_rules</primary>
6155   </indexterm>
6156
6157   <para>
6158    The view <structname>pg_rules</structname> provides access to
6159    useful information about query rewrite rules.
6160   </para>
6161
6162   <table>
6163    <title><structname>pg_rules</> Columns</title>
6164
6165    <tgroup cols=4>
6166     <thead>
6167      <row>
6168       <entry>Name</entry>
6169       <entry>Type</entry>
6170       <entry>References</entry>
6171       <entry>Description</entry>
6172      </row>
6173     </thead>
6174     <tbody>
6175      <row>
6176       <entry><structfield>schemaname</structfield></entry>
6177       <entry><type>name</type></entry>
6178       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
6179       <entry>Name of schema containing table</entry>
6180      </row>
6181      <row>
6182       <entry><structfield>tablename</structfield></entry>
6183       <entry><type>name</type></entry>
6184       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6185       <entry>Name of table the rule is for</entry>
6186      </row>
6187      <row>
6188       <entry><structfield>rulename</structfield></entry>
6189       <entry><type>name</type></entry>
6190       <entry><literal><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link>.rulename</literal></entry>
6191       <entry>Name of rule</entry>
6192      </row>
6193      <row>
6194       <entry><structfield>definition</structfield></entry>
6195       <entry><type>text</type></entry>
6196       <entry></entry>
6197       <entry>Rule definition (a reconstructed creation command)</entry>
6198      </row>
6199     </tbody>
6200    </tgroup>
6201   </table>
6202
6203   <para>
6204    The <structname>pg_rules</> view excludes the <literal>ON SELECT</> rules
6205    of views; those can be seen in <structname>pg_views</>.
6206   </para>
6207
6208  </sect1>
6209
6210  <sect1 id="view-pg-settings">
6211   <title><structname>pg_settings</structname></title>
6212
6213   <indexterm zone="view-pg-settings">
6214    <primary>pg_settings</primary>
6215   </indexterm>
6216
6217   <para>
6218    The view <structname>pg_settings</structname> provides access to
6219    run-time parameters of the server.  It is essentially an alternative
6220    interface to the <command>SHOW</> and <command>SET</> commands.
6221    It also provides access to some facts about each parameter that are
6222    not directly available from <command>SHOW</>, such as minimum and
6223    maximum values.
6224   </para>
6225
6226   <table>
6227    <title><structname>pg_settings</> Columns</title>
6228
6229    <tgroup cols=3>
6230     <thead>
6231      <row>
6232       <entry>Name</entry>
6233       <entry>Type</entry>
6234       <entry>Description</entry>
6235      </row>
6236     </thead>
6237     <tbody>
6238      <row>
6239       <entry><structfield>name</structfield></entry>
6240       <entry><type>text</type></entry>
6241       <entry>Run-time configuration parameter name</entry>
6242      </row>
6243      <row>
6244       <entry><structfield>setting</structfield></entry>
6245       <entry><type>text</type></entry>
6246       <entry>Current value of the parameter</entry>
6247      </row>
6248      <row>
6249       <entry><structfield>unit</structfield></entry>
6250       <entry><type>text</type></entry>
6251       <entry>Implicit unit of the parameter</entry>
6252      </row>
6253      <row>
6254       <entry><structfield>category</structfield></entry>
6255       <entry><type>text</type></entry>
6256       <entry>Logical group of the parameter</entry>
6257      </row>
6258      <row>
6259       <entry><structfield>short_desc</structfield></entry>
6260       <entry><type>text</type></entry>
6261       <entry>A brief description of the parameter</entry>
6262      </row>
6263      <row>
6264       <entry><structfield>extra_desc</structfield></entry>
6265       <entry><type>text</type></entry>
6266       <entry>Additional, more detailed, information about the parameter</entry>
6267      </row>
6268      <row>
6269       <entry><structfield>context</structfield></entry>
6270       <entry><type>text</type></entry>
6271       <entry>Context required to set the parameter's value</entry>
6272      </row>
6273      <row>
6274       <entry><structfield>vartype</structfield></entry>
6275       <entry><type>text</type></entry>
6276       <entry>Parameter type (<literal>bool</>, <literal>enum</>,
6277        <literal>integer</>, <literal>real</>, or <literal>string</>)
6278       </entry>
6279      </row>
6280      <row>
6281       <entry><structfield>source</structfield></entry>
6282       <entry><type>text</type></entry>
6283       <entry>Source of the current parameter value</entry>
6284      </row>
6285      <row>
6286       <entry><structfield>min_val</structfield></entry>
6287       <entry><type>text</type></entry>
6288       <entry>Minimum allowed value of the parameter (NULL for non-numeric
6289       values)</entry>
6290      </row>
6291      <row>
6292       <entry><structfield>max_val</structfield></entry>
6293       <entry><type>text</type></entry>
6294       <entry>Maximum allowed value of the parameter (NULL for non-numeric
6295       values)</entry>
6296      </row>
6297      <row>
6298       <entry><structfield>enumvals</structfield></entry>
6299       <entry><type>text</type></entry>
6300       <entry>Allowed values in enum parameters (NULL for non-enum
6301       values)</entry>
6302      </row>
6303     </tbody>
6304    </tgroup>
6305   </table>
6306   
6307   <para>
6308    The <structname>pg_settings</structname> view cannot be inserted into or
6309    deleted from, but it can be updated.  An <command>UPDATE</command> applied
6310    to a row of <structname>pg_settings</structname> is equivalent to executing
6311    the <xref linkend="sql-set" endterm="sql-set-title"> command on that named
6312    parameter. The change only affects the value used by the current
6313    session. If an <command>UPDATE</command> is issued within a transaction
6314    that is later aborted, the effects of the <command>UPDATE</command> command
6315    disappear when the transaction is rolled back. Once the surrounding
6316    transaction is committed, the effects will persist until the end of the
6317    session, unless overridden by another <command>UPDATE</command> or
6318    <command>SET</command>.
6319   </para>
6320
6321  </sect1>
6322
6323  <sect1 id="view-pg-shadow">
6324   <title><structname>pg_shadow</structname></title>
6325
6326   <indexterm zone="view-pg-shadow">
6327    <primary>pg_shadow</primary>
6328   </indexterm>
6329
6330   <para>
6331    The view <structname>pg_shadow</structname> exists for backwards
6332    compatibility: it emulates a catalog that existed in
6333    <productname>PostgreSQL</productname> before version 8.1.
6334    It shows properties of all roles that are marked as
6335    <structfield>rolcanlogin</>.
6336   </para>
6337
6338   <para>
6339    The name stems from the fact that this table
6340    should not be readable by the public since it contains passwords.
6341    <link linkend="view-pg-user"><structname>pg_user</structname></link>
6342    is a publicly readable view on
6343    <structname>pg_shadow</structname> that blanks out the password field.
6344   </para>
6345
6346   <table>
6347    <title><structname>pg_shadow</> Columns</title>
6348
6349    <tgroup cols=4>
6350     <thead>
6351      <row>
6352       <entry>Name</entry>
6353       <entry>Type</entry>
6354       <entry>References</entry>
6355       <entry>Description</entry>
6356      </row>
6357     </thead>
6358
6359     <tbody>
6360      <row>
6361       <entry><structfield>usename</structfield></entry>
6362       <entry><type>name</type></entry>
6363       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6364       <entry>User name</entry>
6365      </row>
6366
6367      <row>
6368       <entry><structfield>usesysid</structfield></entry>
6369       <entry><type>oid</type></entry>
6370       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6371       <entry>ID of this user</entry>
6372      </row>
6373
6374      <row>
6375       <entry><structfield>usecreatedb</structfield></entry>
6376       <entry><type>bool</type></entry>
6377       <entry></entry>
6378       <entry>User can create databases</entry>
6379      </row>
6380
6381      <row>
6382       <entry><structfield>usesuper</structfield></entry>
6383       <entry><type>bool</type></entry>
6384       <entry></entry>
6385       <entry>User is a superuser</entry>
6386      </row>
6387
6388      <row>
6389       <entry><structfield>usecatupd</structfield></entry>
6390       <entry><type>bool</type></entry>
6391       <entry></entry>
6392       <entry>
6393        User can update system catalogs.  (Even a superuser cannot do
6394        this unless this column is true.)
6395       </entry>
6396      </row>
6397
6398      <row>
6399       <entry><structfield>passwd</structfield></entry>
6400       <entry><type>text</type></entry>
6401       <entry></entry>
6402       <entry>Password (possibly encrypted)</entry>
6403      </row>
6404
6405      <row>
6406       <entry><structfield>valuntil</structfield></entry>
6407       <entry><type>abstime</type></entry>
6408       <entry></entry>
6409       <entry>Password expiry time (only used for password authentication)</entry>
6410      </row>
6411
6412      <row>
6413       <entry><structfield>useconfig</structfield></entry>
6414       <entry><type>text[]</type></entry>
6415       <entry></entry>
6416       <entry>Session defaults for run-time configuration variables</entry>
6417      </row>
6418     </tbody>
6419    </tgroup>
6420   </table>
6421
6422  </sect1>
6423
6424  <sect1 id="view-pg-stats">
6425   <title><structname>pg_stats</structname></title>
6426
6427   <indexterm zone="view-pg-stats">
6428    <primary>pg_stats</primary>
6429   </indexterm>
6430
6431   <para>
6432    The view <structname>pg_stats</structname> provides access to
6433    the information stored in the <link
6434    linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link>
6435    catalog.  This view allows access only to rows of
6436    <structname>pg_statistic</structname> that correspond to tables the
6437    user has permission to read, and therefore it is safe to allow public
6438    read access to this view.
6439   </para>
6440
6441   <para>
6442    <structname>pg_stats</structname> is also designed to present the
6443    information in a more readable format than the underlying catalog
6444    &mdash; at the cost that its schema must be extended whenever new slot types
6445    are defined for <structname>pg_statistic</structname>.
6446   </para>
6447
6448   <table>
6449    <title><structname>pg_stats</> Columns</title>
6450
6451    <tgroup cols=4>
6452     <thead>
6453      <row>
6454       <entry>Name</entry>
6455       <entry>Type</entry>
6456       <entry>References</entry>
6457       <entry>Description</entry>
6458      </row>
6459     </thead>
6460     <tbody>
6461      <row>
6462       <entry><structfield>schemaname</structfield></entry>
6463       <entry><type>name</type></entry>
6464       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
6465       <entry>Name of schema containing table</entry>
6466      </row>
6467
6468      <row>
6469       <entry><structfield>tablename</structfield></entry>
6470       <entry><type>name</type></entry>
6471       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6472       <entry>Name of table</entry>
6473      </row>
6474
6475      <row>
6476       <entry><structfield>attname</structfield></entry>
6477       <entry><type>name</type></entry>
6478       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attname</literal></entry>
6479       <entry>Name of the column described by this row</entry>
6480      </row>
6481
6482      <row>
6483       <entry><structfield>null_frac</structfield></entry>
6484       <entry><type>real</type></entry>
6485       <entry></entry>
6486       <entry>Fraction of column entries that are null</entry>
6487      </row>
6488
6489      <row>
6490       <entry><structfield>avg_width</structfield></entry>
6491       <entry><type>integer</type></entry>
6492       <entry></entry>
6493       <entry>Average width in bytes of column's entries</entry>
6494      </row>
6495
6496      <row>
6497       <entry><structfield>n_distinct</structfield></entry>
6498       <entry><type>real</type></entry>
6499       <entry></entry>
6500       <entry>
6501        If greater than zero, the estimated number of distinct values in the
6502        column.  If less than zero, the negative of the number of distinct
6503        values divided by the number of rows.  (The negated form is used when
6504        <command>ANALYZE</> believes that the number of distinct values is
6505        likely to increase as the table grows; the positive form is used when
6506        the column seems to have a fixed number of possible values.)  For
6507        example, -1 indicates a unique column in which the number of distinct
6508        values is the same as the number of rows
6509       </entry>
6510      </row>
6511
6512      <row>
6513       <entry><structfield>most_common_vals</structfield></entry>
6514       <entry><type>anyarray</type></entry>
6515       <entry></entry>
6516       <entry>
6517        A list of the most common values in the column. (NULL if
6518        no values seem to be more common than any others.)
6519       </entry>
6520      </row>
6521
6522      <row>
6523       <entry><structfield>most_common_freqs</structfield></entry>
6524       <entry><type>real[]</type></entry>
6525       <entry></entry>
6526       <entry>
6527        A list of the frequencies of the most common values,
6528        i.e., number of occurrences of each divided by total number of rows.
6529        (NULL when <structfield>most_common_vals</structfield> is.)
6530      </entry>
6531      </row>
6532
6533      <row>
6534       <entry><structfield>histogram_bounds</structfield></entry>
6535       <entry><type>anyarray</type></entry>
6536       <entry></entry>
6537       <entry>
6538        A list of values that divide the column's values into groups of
6539        approximately equal population.  The values in
6540        <structfield>most_common_vals</>, if present, are omitted from this
6541        histogram calculation.  (This column is NULL if the column data type
6542        does not have a <literal>&lt;</> operator or if the
6543        <structfield>most_common_vals</> list accounts for the entire
6544        population.)
6545       </entry>
6546      </row>
6547
6548      <row>
6549       <entry><structfield>correlation</structfield></entry>
6550       <entry><type>real</type></entry>
6551       <entry></entry>
6552       <entry>
6553        Statistical correlation between physical row ordering and
6554        logical ordering of the column values.  This ranges from -1 to +1.
6555        When the value is near -1 or +1, an index scan on the column will
6556        be estimated to be cheaper than when it is near zero, due to reduction
6557        of random access to the disk.  (This column is NULL if the column data
6558        type does not have a <literal>&lt;</> operator.)
6559       </entry>
6560      </row>
6561     </tbody>
6562    </tgroup>
6563   </table>
6564
6565   <para>
6566    The maximum number of entries in the <structfield>most_common_vals</>
6567    and <structfield>histogram_bounds</> arrays can be set on a
6568    column-by-column basis using the <command>ALTER TABLE SET STATISTICS</>
6569    command, or globally by setting the
6570    <xref linkend="guc-default-statistics-target"> run-time parameter.
6571   </para>
6572
6573  </sect1>
6574
6575  <sect1 id="view-pg-tables">
6576   <title><structname>pg_tables</structname></title>
6577
6578   <indexterm zone="view-pg-tables">
6579    <primary>pg_tables</primary>
6580   </indexterm>
6581
6582   <para>
6583    The view <structname>pg_tables</structname> provides access to
6584    useful information about each table in the database.
6585   </para>
6586
6587   <table>
6588    <title><structname>pg_tables</> Columns</title>
6589
6590    <tgroup cols=4>
6591     <thead>
6592      <row>
6593       <entry>Name</entry>
6594       <entry>Type</entry>
6595       <entry>References</entry>
6596       <entry>Description</entry>
6597      </row>
6598     </thead>
6599     <tbody>
6600      <row>
6601       <entry><structfield>schemaname</structfield></entry>
6602       <entry><type>name</type></entry>
6603       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
6604       <entry>Name of schema containing table</entry>
6605      </row>
6606      <row>
6607       <entry><structfield>tablename</structfield></entry>
6608       <entry><type>name</type></entry>
6609       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6610       <entry>Name of table</entry>
6611      </row>
6612      <row>
6613       <entry><structfield>tableowner</structfield></entry>
6614       <entry><type>name</type></entry>
6615       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6616       <entry>Name of table's owner</entry>
6617      </row>
6618      <row>
6619       <entry><structfield>tablespace</structfield></entry>
6620       <entry><type>name</type></entry>
6621       <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.spcname</literal></entry>
6622       <entry>Name of tablespace containing table (NULL if default for database)</entry>
6623      </row>
6624      <row>
6625       <entry><structfield>hasindexes</structfield></entry>
6626       <entry><type>boolean</type></entry>
6627       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhasindex</literal></entry>
6628       <entry>true if table has (or recently had) any indexes</entry>
6629      </row>
6630      <row>
6631       <entry><structfield>hasrules</structfield></entry>
6632       <entry><type>boolean</type></entry>
6633       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhasrules</literal></entry>
6634       <entry>true if table has rules</entry>
6635      </row>
6636      <row>
6637       <entry><structfield>hastriggers</structfield></entry>
6638       <entry><type>boolean</type></entry>
6639       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.reltriggers</literal></entry>
6640       <entry>true if table has triggers</entry>
6641      </row>
6642     </tbody>
6643    </tgroup>
6644   </table>
6645
6646  </sect1>
6647
6648  <sect1 id="view-pg-timezone-abbrevs">
6649   <title><structname>pg_timezone_abbrevs</structname></title>
6650
6651   <indexterm zone="view-pg-timezone-abbrevs">
6652    <primary>pg_timezone_abbrevs</primary>
6653   </indexterm>
6654
6655   <para>
6656    The view <structname>pg_timezone_abbrevs</structname> provides a list
6657    of time zone abbreviations that are currently recognized by the datetime
6658    input routines.  The contents of this view change when the
6659    <xref linkend="guc-timezone-abbreviations"> run-time parameter is modified.
6660   </para>
6661
6662   <table>
6663    <title><structname>pg_timezone_abbrevs</> Columns</title>
6664
6665    <tgroup cols=3>
6666     <thead>
6667      <row>
6668       <entry>Name</entry>
6669       <entry>Type</entry>
6670       <entry>Description</entry>
6671      </row>
6672     </thead>
6673     <tbody>
6674      <row>
6675       <entry><structfield>abbrev</structfield></entry>
6676       <entry><type>text</type></entry>
6677       <entry>Time zone abbreviation</entry>
6678      </row>
6679      <row>
6680       <entry><structfield>utc_offset</structfield></entry>
6681       <entry><type>interval</type></entry>
6682       <entry>Offset from UTC (positive means east of Greenwich)</entry>
6683      </row>
6684      <row>
6685       <entry><structfield>is_dst</structfield></entry>
6686       <entry><type>boolean</type></entry>
6687       <entry>True if this is a daylight-savings abbreviation</entry>
6688      </row>
6689     </tbody>
6690    </tgroup>
6691   </table>
6692
6693  </sect1>
6694
6695  <sect1 id="view-pg-timezone-names">
6696   <title><structname>pg_timezone_names</structname></title>
6697
6698   <indexterm zone="view-pg-timezone-names">
6699    <primary>pg_timezone_names</primary>
6700   </indexterm>
6701
6702   <para>
6703    The view <structname>pg_timezone_names</structname> provides a list
6704    of time zone names that are recognized by <command>SET TIMEZONE</>,
6705    along with their associated abbreviations, UTC offsets,
6706    and daylight-savings status.
6707    Unlike the abbreviations shown in <link
6708    linkend="view-pg-timezone-abbrevs"><structname>pg_timezone_abbrevs</structname></link>, many of these names imply a set of daylight-savings transition
6709    date rules.  Therefore, the associated information changes across local DST
6710    boundaries.  The displayed information is computed based on the current
6711    value of <function>CURRENT_TIMESTAMP</>.
6712   </para>
6713
6714   <table>
6715    <title><structname>pg_timezone_names</> Columns</title>
6716
6717    <tgroup cols=3>
6718     <thead>
6719      <row>
6720       <entry>Name</entry>
6721       <entry>Type</entry>
6722       <entry>Description</entry>
6723      </row>
6724     </thead>
6725     <tbody>
6726      <row>
6727       <entry><structfield>name</structfield></entry>
6728       <entry><type>text</type></entry>
6729       <entry>Time zone name</entry>
6730      </row>
6731      <row>
6732       <entry><structfield>abbrev</structfield></entry>
6733       <entry><type>text</type></entry>
6734       <entry>Time zone abbreviation</entry>
6735      </row>
6736      <row>
6737       <entry><structfield>utc_offset</structfield></entry>
6738       <entry><type>interval</type></entry>
6739       <entry>Offset from UTC (positive means east of Greenwich)</entry>
6740      </row>
6741      <row>
6742       <entry><structfield>is_dst</structfield></entry>
6743       <entry><type>boolean</type></entry>
6744       <entry>True if currently observing daylight savings</entry>
6745      </row>
6746     </tbody>
6747    </tgroup>
6748   </table>
6749
6750  </sect1>
6751
6752  <sect1 id="view-pg-user">
6753   <title><structname>pg_user</structname></title>
6754
6755   <indexterm zone="view-pg-user">
6756    <primary>pg_user</primary>
6757   </indexterm>
6758
6759   <para>
6760    The view <structname>pg_user</structname> provides access to
6761    information about database users.  This is simply a publicly
6762    readable view of 
6763    <link linkend="view-pg-shadow"><structname>pg_shadow</structname></link>
6764    that blanks out the password field.
6765   </para>
6766
6767   <table>
6768    <title><structname>pg_user</> Columns</title>
6769
6770    <tgroup cols=3>
6771     <thead>
6772      <row>
6773       <entry>Name</entry>
6774       <entry>Type</entry>
6775       <entry>Description</entry>
6776      </row>
6777     </thead>
6778     <tbody>
6779      <row>
6780       <entry><structfield>usename</structfield></entry>
6781       <entry><type>name</type></entry>
6782       <entry>User name</entry>
6783      </row>
6784
6785      <row>
6786       <entry><structfield>usesysid</structfield></entry>
6787       <entry><type>int4</type></entry>
6788       <entry>User ID (arbitrary number used to reference this user)</entry>
6789      </row>
6790
6791      <row>
6792       <entry><structfield>usecreatedb</structfield></entry>
6793       <entry><type>bool</type></entry>
6794       <entry>User can create databases</entry>
6795      </row>
6796
6797      <row>
6798       <entry><structfield>usesuper</structfield></entry>
6799       <entry><type>bool</type></entry>
6800       <entry>User is a superuser</entry>
6801      </row>
6802
6803      <row>
6804       <entry><structfield>usecatupd</structfield></entry>
6805       <entry><type>bool</type></entry>
6806       <entry>
6807        User can update system catalogs.  (Even a superuser cannot do
6808        this unless this column is true.)
6809       </entry>
6810      </row>
6811
6812      <row>
6813       <entry><structfield>passwd</structfield></entry>
6814       <entry><type>text</type></entry>
6815       <entry>Not the password (always reads as <literal>********</>)</entry>
6816      </row>
6817
6818      <row>
6819       <entry><structfield>valuntil</structfield></entry>
6820       <entry><type>abstime</type></entry>
6821       <entry>Password expiry time (only used for password authentication)</entry>
6822      </row>
6823
6824      <row>
6825       <entry><structfield>useconfig</structfield></entry>
6826       <entry><type>text[]</type></entry>
6827       <entry>Session defaults for run-time configuration variables</entry>
6828      </row>
6829     </tbody>
6830    </tgroup>
6831   </table>
6832
6833  </sect1>
6834
6835  <sect1 id="view-pg-views">
6836   <title><structname>pg_views</structname></title>
6837
6838   <indexterm zone="view-pg-views">
6839    <primary>pg_views</primary>
6840   </indexterm>
6841
6842   <para>
6843    The view <structname>pg_views</structname> provides access to
6844    useful information about each view in the database.
6845   </para>
6846
6847   <table>
6848    <title><structname>pg_views</> Columns</title>
6849
6850    <tgroup cols=4>
6851     <thead>
6852      <row>
6853       <entry>Name</entry>
6854       <entry>Type</entry>
6855       <entry>References</entry>
6856       <entry>Description</entry>
6857      </row>
6858     </thead>
6859     <tbody>
6860      <row>
6861       <entry><structfield>schemaname</structfield></entry>
6862       <entry><type>name</type></entry>
6863       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
6864       <entry>Name of schema containing view</entry>
6865      </row>
6866      <row>
6867       <entry><structfield>viewname</structfield></entry>
6868       <entry><type>name</type></entry>
6869       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
6870       <entry>Name of view</entry>
6871      </row>
6872      <row>
6873       <entry><structfield>viewowner</structfield></entry>
6874       <entry><type>name</type></entry>
6875       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6876       <entry>Name of view's owner</entry>
6877      </row>
6878      <row>
6879       <entry><structfield>definition</structfield></entry>
6880       <entry><type>text</type></entry>
6881       <entry></entry>
6882       <entry>View definition (a reconstructed <command>SELECT</command> query)</entry>
6883      </row>
6884     </tbody>
6885    </tgroup>
6886   </table>
6887
6888  </sect1>
6889
6890 </chapter>