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