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