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