catalogs.sgml 198 KB
Newer Older
1
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.132 2006/09/16 20:14:32 tgl Exp $ -->
2 3 4 5 6 7 8 9 10 11 12 13 14 15
<!--
 Documentation of the system catalogs, directed toward PostgreSQL developers
 -->

<chapter id="catalogs">
 <title>System Catalogs</title>

  <para>
   The system catalogs are the place where a relational database
   management system stores schema metadata, such as information about
   tables and columns, and internal bookkeeping information.
   <productname>PostgreSQL</productname>'s system catalogs are regular
   tables.  You can drop and recreate the tables, add columns, insert
   and update values, and severely mess up your system that way.
16
   Normally, one should not change the system catalogs by hand, there
17 18
   are always SQL commands to do that.  (For example, <command>CREATE
   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 22 23 24 25 26 27 28 29
   particularly esoteric operations, such as adding index access methods.
  </para>

 <sect1 id="catalogs-overview">
  <title>Overview</title>

  <para>
   <xref linkend="catalog-table"> lists the system catalogs.
   More detailed documentation of each catalog follows below.
30
  </para>
31

32 33
  <para>
   Most system catalogs are copied from the template database during
34 35
   database creation and are thereafter database-specific. A few
   catalogs are physically shared across all databases in a cluster;
36
   these are noted in the descriptions of the individual catalogs.
37
  </para>
38

39
  <table id="catalog-table">
40 41 42 43 44 45 46 47 48 49 50 51
   <title>System Catalogs</title>

   <tgroup cols="2">
    <thead>
     <row>
      <entry>Catalog Name</entry>
      <entry>Purpose</entry>
     </row>
    </thead>

    <tbody>
     <row>
52
      <entry><link linkend="catalog-pg-aggregate"><structname>pg_aggregate</structname></link></entry>
53 54 55 56
      <entry>aggregate functions</entry>
     </row>

     <row>
57
      <entry><link linkend="catalog-pg-am"><structname>pg_am</structname></link></entry>
58 59 60 61
      <entry>index access methods</entry>
     </row>

     <row>
62
      <entry><link linkend="catalog-pg-amop"><structname>pg_amop</structname></link></entry>
63 64 65 66
      <entry>access method operators</entry>
     </row>

     <row>
67
      <entry><link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link></entry>
68 69 70 71
      <entry>access method support procedures</entry>
     </row>

     <row>
72
      <entry><link linkend="catalog-pg-attrdef"><structname>pg_attrdef</structname></link></entry>
73 74 75 76
      <entry>column default values</entry>
     </row>

     <row>
77 78
      <entry><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link></entry>
      <entry>table columns (<quote>attributes</quote>)</entry>
79 80
     </row>

81 82 83 84 85 86 87 88 89 90
     <row>
      <entry><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link></entry>
      <entry>authorization identifiers (roles)</entry>
     </row>

     <row>
      <entry><link linkend="catalog-pg-auth-members"><structname>pg_auth_members</structname></link></entry>
      <entry>authorization identifier membership relationships</entry>
     </row>

91 92 93 94 95
     <row>
      <entry><link linkend="catalog-pg-autovacuum"><structname>pg_autovacuum</structname></link></entry>
      <entry>per-relation autovacuum configuration parameters</entry>
     </row>

96
     <row>
97
      <entry><link linkend="catalog-pg-cast"><structname>pg_cast</structname></link></entry>
98 99 100
      <entry>casts (data type conversions)</entry>
     </row>

101
     <row>
102
      <entry><link linkend="catalog-pg-class"><structname>pg_class</structname></link></entry>
103
      <entry>tables, indexes, sequences, views (<quote>relations</quote>)</entry>
104 105
     </row>

106
     <row>
107 108
      <entry><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link></entry>
      <entry>check constraints, unique constraints, primary key constraints, foreign key constraints</entry>
109 110
     </row>

111
     <row>
112
      <entry><link linkend="catalog-pg-conversion"><structname>pg_conversion</structname></link></entry>
113 114 115
      <entry>encoding conversion information</entry>
     </row>

116
     <row>
117
      <entry><link linkend="catalog-pg-database"><structname>pg_database</structname></link></entry>
118
      <entry>databases within this database cluster</entry>
119 120
     </row>

121
     <row>
122
      <entry><link linkend="catalog-pg-depend"><structname>pg_depend</structname></link></entry>
123 124 125
      <entry>dependencies between database objects</entry>
     </row>

126
     <row>
127
      <entry><link linkend="catalog-pg-description"><structname>pg_description</structname></link></entry>
128 129 130 131
      <entry>descriptions or comments on database objects</entry>
     </row>

     <row>
132
      <entry><link linkend="catalog-pg-index"><structname>pg_index</structname></link></entry>
133 134 135 136
      <entry>additional index information</entry>
     </row>

     <row>
137
      <entry><link linkend="catalog-pg-inherits"><structname>pg_inherits</structname></link></entry>
138 139 140 141
      <entry>table inheritance hierarchy</entry>
     </row>

     <row>
142
      <entry><link linkend="catalog-pg-language"><structname>pg_language</structname></link></entry>
143 144 145 146
      <entry>languages for writing functions</entry>
     </row>

     <row>
147
      <entry><link linkend="catalog-pg-largeobject"><structname>pg_largeobject</structname></link></entry>
148 149 150 151
      <entry>large objects</entry>
     </row>

     <row>
152 153
      <entry><link linkend="catalog-pg-listener"><structname>pg_listener</structname></link></entry>
      <entry>asynchronous notification support</entry>
154 155
     </row>

156
     <row>
157 158
      <entry><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link></entry>
      <entry>schemas</entry>
159 160
     </row>

161
     <row>
162
      <entry><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link></entry>
163 164 165 166
      <entry>index access method operator classes</entry>
     </row>

     <row>
167
      <entry><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link></entry>
168 169 170
      <entry>operators</entry>
     </row>

171 172 173 174 175
     <row>
      <entry><link linkend="catalog-pg-pltemplate"><structname>pg_pltemplate</structname></link></entry>
      <entry>template data for procedural languages</entry>
     </row>

176
     <row>
177
      <entry><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link></entry>
178 179 180 181
      <entry>functions and procedures</entry>
     </row>

     <row>
182 183
      <entry><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link></entry>
      <entry>query rewrite rules</entry>
184 185
     </row>

186 187 188 189 190
     <row>
      <entry><link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link></entry>
      <entry>dependencies on shared objects</entry>
     </row>

191 192 193 194 195
     <row>
      <entry><link linkend="catalog-pg-shdescription"><structname>pg_shdescription</structname></link></entry>
      <entry>comments on shared objects</entry>
     </row>

196
     <row>
197 198
      <entry><link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link></entry>
      <entry>planner statistics</entry>
199 200
     </row>

201 202 203 204 205
     <row>
      <entry><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link></entry>
      <entry>tablespaces within this database cluster</entry>
     </row>

206
     <row>
207
      <entry><link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link></entry>
208 209 210 211
      <entry>triggers</entry>
     </row>

     <row>
212
      <entry><link linkend="catalog-pg-type"><structname>pg_type</structname></link></entry>
213 214 215 216 217
      <entry>data types</entry>
     </row>
    </tbody>
   </tgroup>
  </table>
218
 </sect1>
219 220


221
 <sect1 id="catalog-pg-aggregate">
222 223 224 225 226
  <title><structname>pg_aggregate</structname></title>

  <indexterm zone="catalog-pg-aggregate">
   <primary>pg_aggregate</primary>
  </indexterm>
227 228

  <para>
229
   The catalog <structname>pg_aggregate</structname> stores information about
230
   aggregate functions.  An aggregate function is a function that
231
   operates on a set of values (typically one column from each row
232 233 234
   that matches a query condition) and returns a single value computed
   from all these values.  Typical aggregate functions are
   <function>sum</function>, <function>count</function>, and
235 236 237
   <function>max</function>.  Each entry in
   <structname>pg_aggregate</structname> is an extension of an entry
   in <structname>pg_proc</structname>.  The <structname>pg_proc</structname>
238
   entry carries the aggregate's name, input and output data types, and
239
   other information that is similar to ordinary functions.
240 241 242
  </para>

  <table>
243
   <title><structname>pg_aggregate</> Columns</title>
244 245 246 247 248 249 250 251 252 253 254 255

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
256
      <entry><structfield>aggfnoid</structfield></entry>
257
      <entry><type>regproc</type></entry>
258
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
259
      <entry><structname>pg_proc</structname> OID of the aggregate function</entry>
260 261
     </row>
     <row>
262
      <entry><structfield>aggtransfn</structfield></entry>
263
      <entry><type>regproc</type></entry>
264
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
265 266 267
      <entry>Transition function</entry>
     </row>
     <row>
268
      <entry><structfield>aggfinalfn</structfield></entry>
269
      <entry><type>regproc</type></entry>
270
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
271
      <entry>Final function (zero if none)</entry>
272
     </row>
273 274 275 276 277 278
     <row>
      <entry><structfield>aggsortop</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
      <entry>Associated sort operator (zero if none)</entry>
     </row>
279
     <row>
280
      <entry><structfield>aggtranstype</structfield></entry>
281
      <entry><type>oid</type></entry>
282
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
283
      <entry>Data type of the aggregate function's internal transition (state) data</entry>
284 285
     </row>
     <row>
286
      <entry><structfield>agginitval</structfield></entry>
287 288 289 290
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>
       The initial value of the transition state.  This is a text
291
       field containing the initial value in its external string
292 293
       representation.  If this field is NULL, the transition state
       value starts out NULL.
294 295 296 297 298 299 300
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
301 302 303 304 305
   New aggregate functions are registered with the <xref
   linkend="sql-createaggregate" endterm="sql-createaggregate-title">
   command.  See <xref linkend="xaggr"> for more information about
   writing aggregate functions and the meaning of the transition
   functions, etc.
306 307
  </para>

308
 </sect1>
309 310


311
 <sect1 id="catalog-pg-am">
312 313 314 315 316
  <title><structname>pg_am</structname></title>

  <indexterm zone="catalog-pg-am">
   <primary>pg_am</primary>
  </indexterm>
317 318

  <para>
319 320 321 322
   The catalog <structname>pg_am</structname> stores information about index
   access methods.  There is one row for each index access method supported by
   the system.  The contents of this catalog are discussed in detail in
   <xref linkend="indexam">.
323 324 325
  </para>

  <table>
326
   <title><structname>pg_am</> Columns</title>
327 328 329 330 331 332 333 334 335 336 337 338 339

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>

     <row>
340
      <entry><structfield>amname</structfield></entry>
341 342
      <entry><type>name</type></entry>
      <entry></entry>
343
      <entry>Name of the access method</entry>
344 345 346
     </row>

     <row>
347
      <entry><structfield>amstrategies</structfield></entry>
348 349
      <entry><type>int2</type></entry>
      <entry></entry>
350
      <entry>Number of operator strategies for this access method</entry>
351 352 353
     </row>

     <row>
354
      <entry><structfield>amsupport</structfield></entry>
355 356
      <entry><type>int2</type></entry>
      <entry></entry>
357
      <entry>Number of support routines for this access method</entry>
358 359 360
     </row>

     <row>
361
      <entry><structfield>amorderstrategy</structfield></entry>
362 363
      <entry><type>int2</type></entry>
      <entry></entry>
364
      <entry>Zero if the index offers no sort order, otherwise the strategy
365 366 367 368
      number of the strategy operator that describes the sort order</entry>
     </row>

     <row>
369
      <entry><structfield>amcanunique</structfield></entry>
370 371
      <entry><type>bool</type></entry>
      <entry></entry>
372
      <entry>Does the access method support unique indexes?</entry>
373 374 375
     </row>

     <row>
376
      <entry><structfield>amcanmulticol</structfield></entry>
377 378
      <entry><type>bool</type></entry>
      <entry></entry>
379
      <entry>Does the access method support multicolumn indexes?</entry>
380 381
     </row>

382 383 384 385 386 387 388 389
     <row>
      <entry><structfield>amoptionalkey</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Does the access method support a scan without any constraint
       for the first index column?</entry>
     </row>

390
     <row>
391
      <entry><structfield>amindexnulls</structfield></entry>
392 393
      <entry><type>bool</type></entry>
      <entry></entry>
394
      <entry>Does the access method support null index entries?</entry>
395 396
     </row>

397 398 399 400 401 402 403 404 405 406 407 408 409 410
     <row>
      <entry><structfield>amstorage</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Can index storage data type differ from column data type?</entry>
     </row>

     <row>
      <entry><structfield>amclusterable</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Can an index of this type be CLUSTERed on?</entry>
     </row>

411
     <row>
412
      <entry><structfield>aminsert</structfield></entry>
413
      <entry><type>regproc</type></entry>
414
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
415
      <entry><quote>Insert this tuple</quote> function</entry>
416 417 418
     </row>

     <row>
419
      <entry><structfield>ambeginscan</structfield></entry>
420
      <entry><type>regproc</type></entry>
421
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
422
      <entry><quote>Start new scan</quote> function</entry>
423 424 425
     </row>

     <row>
426
      <entry><structfield>amgettuple</structfield></entry>
427
      <entry><type>regproc</type></entry>
428
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
429 430 431 432 433 434 435 436
      <entry><quote>Next valid tuple</quote> function</entry>
     </row>

     <row>
      <entry><structfield>amgetmulti</structfield></entry>
      <entry><type>regproc</type></entry>
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
      <entry><quote>Fetch multiple tuples</quote> function</entry>
437 438 439
     </row>

     <row>
440
      <entry><structfield>amrescan</structfield></entry>
441
      <entry><type>regproc</type></entry>
442
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
443
      <entry><quote>Restart this scan</quote> function</entry>
444 445 446
     </row>

     <row>
447
      <entry><structfield>amendscan</structfield></entry>
448
      <entry><type>regproc</type></entry>
449
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
450
      <entry><quote>End this scan</quote> function</entry>
451 452 453
     </row>

     <row>
454
      <entry><structfield>ammarkpos</structfield></entry>
455
      <entry><type>regproc</type></entry>
456
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
457
      <entry><quote>Mark current scan position</quote> function</entry>
458 459 460
     </row>

     <row>
461
      <entry><structfield>amrestrpos</structfield></entry>
462
      <entry><type>regproc</type></entry>
463
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
464
      <entry><quote>Restore marked scan position</quote> function</entry>
465 466 467
     </row>

     <row>
468
      <entry><structfield>ambuild</structfield></entry>
469
      <entry><type>regproc</type></entry>
470
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
471
      <entry><quote>Build new index</quote> function</entry>
472 473 474
     </row>

     <row>
475
      <entry><structfield>ambulkdelete</structfield></entry>
476
      <entry><type>regproc</type></entry>
477
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
478
      <entry>Bulk-delete function</entry>
479 480
     </row>

481
     <row>
482
      <entry><structfield>amvacuumcleanup</structfield></entry>
483
      <entry><type>regproc</type></entry>
484
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
485
      <entry>Post-<command>VACUUM</command> cleanup function</entry>
486 487
     </row>

488
     <row>
489
      <entry><structfield>amcostestimate</structfield></entry>
490
      <entry><type>regproc</type></entry>
491
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
492
      <entry>Function to estimate cost of an index scan</entry>
493 494
     </row>

495 496 497 498 499 500 501
     <row>
      <entry><structfield>amoptions</structfield></entry>
      <entry><type>regproc</type></entry>
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
      <entry>Function to parse and validate reloptions for an index</entry>
     </row>

502 503 504 505 506 507 508 509
    </tbody>
   </tgroup>
  </table>

 </sect1>


 <sect1 id="catalog-pg-amop">
510 511 512 513 514
  <title><structname>pg_amop</structname></title>

  <indexterm zone="catalog-pg-amop">
   <primary>pg_amop</primary>
  </indexterm>
515 516

  <para>
517
   The catalog <structname>pg_amop</structname> stores information about operators
518 519 520 521 522
   associated with index access method operator classes.  There is one
   row for each operator that is a member of an operator class.
  </para>

  <table>
523
   <title><structname>pg_amop</> Columns</title>
524 525 526 527 528 529 530 531 532 533 534 535 536

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>

     <row>
537
      <entry><structfield>amopclaid</structfield></entry>
538
      <entry><type>oid</type></entry>
539
      <entry><literal><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.oid</literal></entry>
540
      <entry>The index operator class this entry is for</entry>
541 542
     </row>

543 544 545 546 547 548 549 550
     <row>
      <entry><structfield>amopsubtype</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
      <entry>Subtype to distinguish multiple entries for one strategy;
             zero for default</entry>
     </row>

551
     <row>
552
      <entry><structfield>amopstrategy</structfield></entry>
553 554
      <entry><type>int2</type></entry>
      <entry></entry>
555
      <entry>Operator strategy number</entry>
556 557 558
     </row>

     <row>
559
      <entry><structfield>amopreqcheck</structfield></entry>
560 561
      <entry><type>bool</type></entry>
      <entry></entry>
562
      <entry>Index hit must be rechecked</entry>
563 564 565
     </row>

     <row>
566
      <entry><structfield>amopopr</structfield></entry>
567
      <entry><type>oid</type></entry>
568
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
569
      <entry>OID of the operator</entry>
570 571 572 573 574 575 576 577 578 579
     </row>

    </tbody>
   </tgroup>
  </table>

 </sect1>


 <sect1 id="catalog-pg-amproc">
580 581 582 583 584
  <title><structname>pg_amproc</structname></title>

  <indexterm zone="catalog-pg-amproc">
   <primary>pg_amproc</primary>
  </indexterm>
585 586

  <para>
587
   The catalog <structname>pg_amproc</structname> stores information about support
588 589 590 591 592 593
   procedures
   associated with index access method operator classes.  There is one
   row for each support procedure belonging to an operator class.
  </para>

  <table>
594
   <title><structname>pg_amproc</structname> Columns</title>
595 596 597 598 599 600 601 602 603 604 605 606 607

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>

     <row>
608
      <entry><structfield>amopclaid</structfield></entry>
609
      <entry><type>oid</type></entry>
610
      <entry><literal><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.oid</literal></entry>
611
      <entry>The index operator class this entry is for</entry>
612 613
     </row>

614 615 616 617 618 619 620
     <row>
      <entry><structfield>amprocsubtype</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
      <entry>Subtype, if cross-type routine, else zero</entry>
     </row>

621
     <row>
622
      <entry><structfield>amprocnum</structfield></entry>
623 624
      <entry><type>int2</type></entry>
      <entry></entry>
625
      <entry>Support procedure number</entry>
626 627 628
     </row>

     <row>
629
      <entry><structfield>amproc</structfield></entry>
630
      <entry><type>regproc</type></entry>
631
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
632
      <entry>OID of the procedure</entry>
633 634 635 636 637 638 639 640 641
     </row>

    </tbody>
   </tgroup>
  </table>

 </sect1>


642
 <sect1 id="catalog-pg-attrdef">
643 644 645 646 647
  <title><structname>pg_attrdef</structname></title>

  <indexterm zone="catalog-pg-attrdef">
   <primary>pg_attrdef</primary>
  </indexterm>
648 649

  <para>
650
   The catalog <structname>pg_attrdef</structname> stores column default values.  The main information
651 652 653 654 655 656 657
   about columns is stored in <structname>pg_attribute</structname>
   (see below).  Only columns that explicitly specify a default value
   (when the table is created or the column is added) will have an
   entry here.
  </para>

  <table>
658
   <title><structname>pg_attrdef</> Columns</title>
659 660 661 662 663 664 665 666 667 668 669 670 671

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
672
      <entry><structfield>adrelid</structfield></entry>
673
      <entry><type>oid</type></entry>
674
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
675 676 677 678
      <entry>The table this column belongs to</entry>
     </row>

     <row>
679
      <entry><structfield>adnum</structfield></entry>
680
      <entry><type>int2</type></entry>
681
      <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
682
      <entry>The number of the column</entry>
683 684 685
     </row>

     <row>
686
      <entry><structfield>adbin</structfield></entry>
687 688
      <entry><type>text</type></entry>
      <entry></entry>
689
      <entry>The internal representation of the column default value</entry>
690 691 692
     </row>

     <row>
693
      <entry><structfield>adsrc</structfield></entry>
694 695 696 697 698 699 700 701
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>A human-readable representation of the default value</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

702 703 704 705 706 707 708 709
   <para>
    The <structfield>adsrc</structfield> field is historical, and is best
    not used, because it does not track outside changes that might affect
    the representation of the default value.  Reverse-compiling the
    <structfield>adbin</structfield> field (with <function>pg_get_expr</> for
    example) is a better way to display the default value.
   </para>

710
 </sect1>
711 712


713
 <sect1 id="catalog-pg-attribute">
714 715 716 717 718
  <title><structname>pg_attribute</structname></title>

  <indexterm zone="catalog-pg-attribute">
   <primary>pg_attribute</primary>
  </indexterm>
719 720

  <para>
721
   The catalog <structname>pg_attribute</structname> stores information about
722 723 724
   table columns.  There will be exactly one
   <structname>pg_attribute</structname> row for every column in every
   table in the database.  (There will also be attribute entries for
725 726
   indexes, and indeed all objects that have <structname>pg_class</structname>
   entries.)
727 728 729 730 731 732 733 734
  </para>

  <para>
   The term attribute is equivalent to column and is used for
   historical reasons.
  </para>

  <table>
735
   <title><structname>pg_attribute</> Columns</title>
736 737 738 739 740 741 742 743 744 745 746 747 748

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
749
      <entry><structfield>attrelid</structfield></entry>
750
      <entry><type>oid</type></entry>
751
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
752 753 754 755
      <entry>The table this column belongs to</entry>
     </row>

     <row>
756
      <entry><structfield>attname</structfield></entry>
757 758
      <entry><type>name</type></entry>
      <entry></entry>
759
      <entry>The column name</entry>
760 761 762
     </row>

     <row>
763
      <entry><structfield>atttypid</structfield></entry>
764
      <entry><type>oid</type></entry>
765
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
766 767 768 769
      <entry>The data type of this column</entry>
     </row>

     <row>
770
      <entry><structfield>attstattarget</structfield></entry>
771
      <entry><type>int4</type></entry>
772 773
      <entry></entry>
      <entry>
774 775
       <structfield>attstattarget</structfield> controls the level of detail
       of statistics accumulated for this column by
776
       <xref linkend="sql-analyze" endterm="sql-analyze-title">.
777
       A zero value indicates that no statistics should be collected.
778
       A negative value says to use the system default statistics target.
779 780
       The exact meaning of positive values is data type-dependent.
       For scalar data types, <structfield>attstattarget</structfield>
781 782
       is both the target number of <quote>most common values</quote>
       to collect, and the target number of histogram bins to create.
783 784 785 786
      </entry>
     </row>

     <row>
787
      <entry><structfield>attlen</structfield></entry>
788 789 790
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>
791 792
       A copy of <literal>pg_type.typlen</literal> of this column's
       type
793 794 795 796
      </entry>
     </row>

     <row>
797
      <entry><structfield>attnum</structfield></entry>
798 799 800 801 802 803 804 805 806 807
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>
       The number of the column.  Ordinary columns are numbered from 1
       up.  System columns, such as <structfield>oid</structfield>,
       have (arbitrary) negative numbers.
      </entry>
     </row>

     <row>
808
      <entry><structfield>attndims</structfield></entry>
809 810
      <entry><type>int4</type></entry>
      <entry></entry>
811
      <entry>
812 813 814
       Number of dimensions, if the column is an array type; otherwise 0.
       (Presently, the number of dimensions of an array is not enforced,
       so any nonzero value effectively means <quote>it's an array</>.)
815
      </entry>
816 817 818
     </row>

     <row>
819
      <entry><structfield>attcacheoff</structfield></entry>
820 821 822
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
823
       Always -1 in storage, but when loaded into a row descriptor
824
       in memory this may be updated to cache the offset of the attribute
825
       within the row.
826 827 828 829
      </entry>
     </row>

     <row>
830
      <entry><structfield>atttypmod</structfield></entry>
831 832 833 834 835 836
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
       <structfield>atttypmod</structfield> records type-specific data
       supplied at table creation time (for example, the maximum
       length of a <type>varchar</type> column).  It is passed to
837
       type-specific input functions and length coercion functions.
838
       The value will generally be -1 for types that do not need <structfield>atttypmod</>.
839 840 841 842
      </entry>
     </row>

     <row>
843
      <entry><structfield>attbyval</structfield></entry>
844 845 846
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
847
       A copy of <literal>pg_type.typbyval</> of this column's type
848 849 850 851
      </entry>
     </row>

     <row>
852
      <entry><structfield>attstorage</structfield></entry>
853 854 855
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
856 857
       Normally a copy of <literal>pg_type.typstorage</> of this
       column's type.  For TOAST-able data types, this can be altered
858
       after column creation to control storage policy.
859 860 861 862
      </entry>
     </row>

     <row>
863
      <entry><structfield>attalign</structfield></entry>
864 865 866
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
867
       A copy of <literal>pg_type.typalign</> of this column's type
868 869 870 871
      </entry>
     </row>

     <row>
872
      <entry><structfield>attnotnull</structfield></entry>
873 874 875
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
876 877
       This represents a not-null constraint.  It is possible to
       change this column to enable or disable the constraint.
878 879 880 881
      </entry>
     </row>

     <row>
882
      <entry><structfield>atthasdef</structfield></entry>
883 884 885 886 887 888 889 890 891
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       This column has a default value, in which case there will be a
       corresponding entry in the <structname>pg_attrdef</structname>
       catalog that actually defines the value.
      </entry>
     </row>

892
     <row>
893
      <entry><structfield>attisdropped</structfield></entry>
894 895 896 897 898 899 900 901 902
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       This column has been dropped and is no longer valid.  A dropped
       column is still physically present in the table, but is
       ignored by the parser and so cannot be accessed via SQL.
      </entry>
     </row>

903
     <row>
904
      <entry><structfield>attislocal</structfield></entry>
905 906 907
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
908 909 910 911 912 913
       This column is defined locally in the relation.  Note that a column may
       be locally defined and inherited simultaneously.
      </entry>
     </row>

     <row>
914
      <entry><structfield>attinhcount</structfield></entry>
915 916 917 918 919
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
       The number of direct ancestors this column has.  A column with a 
       nonzero number of ancestors cannot be dropped nor renamed.
920 921 922
      </entry>
     </row>

923 924 925
    </tbody>
   </tgroup>
  </table>
926 927 928 929 930 931 932 933 934 935 936

  <para>
   In a dropped column's <structname>pg_attribute</structname> entry,
   <structfield>atttypid</structfield> is reset to zero, but 
   <structfield>attlen</structfield> and the other fields copied from
   <structname>pg_type</> are still valid.  This arrangement is needed
   to cope with the situation where the dropped column's data type was
   later dropped, and so there is no <structname>pg_type</> row anymore.
   <structfield>attlen</structfield> and the other fields can be used
   to interpret the contents of a row of the table.
  </para>
937
 </sect1>
938 939


940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
 <sect1 id="catalog-pg-authid">
  <title><structname>pg_authid</structname></title>

  <indexterm zone="catalog-pg-authid">
   <primary>pg_authid</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_authid</structname> contains information about
   database authorization identifiers (roles).  A role subsumes the concepts
   of <quote>users</> and <quote>groups</>.  A user is essentially just a
   role with the <structfield>rolcanlogin</> flag set.  Any role (with or
   without <structfield>rolcanlogin</>) may have other roles as members; see
   <link linkend="catalog-pg-auth-members"><structname>pg_auth_members</structname></link>.
  </para>

  <para>
   Since this catalog contains passwords, it must not be publicly readable.
   <link linkend="view-pg-roles"><structname>pg_roles</structname></link>
   is a publicly readable view on
   <structname>pg_authid</structname> that blanks out the password field.
  </para>

  <para>
   <xref linkend="user-manag"> contains detailed information about user and
   privilege management.
  </para>

  <para>
   Because user identities are cluster-wide,
   <structname>pg_authid</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_authid</structname> per cluster, not
   one per database.
  </para>

  <table>
   <title><structname>pg_authid</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>rolname</structfield></entry>
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Role name</entry>
     </row>

     <row>
      <entry><structfield>rolsuper</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role has superuser privileges</entry>
     </row>

1004 1005 1006 1007 1008 1009 1010 1011
     <row>
      <entry><structfield>rolinherit</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role automatically inherits privileges of roles it is a
       member of</entry>
     </row>

1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
     <row>
      <entry><structfield>rolcreaterole</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role may create more roles</entry>
     </row>

     <row>
      <entry><structfield>rolcreatedb</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role may create databases</entry>
     </row>

     <row>
      <entry><structfield>rolcatupdate</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       Role may update system catalogs directly.  (Even a superuser may not do
       this unless this column is true.)
      </entry>
     </row>

     <row>
      <entry><structfield>rolcanlogin</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
1041
       Role may log in. That is, this role can be given as the initial
1042 1043 1044 1045
       session authorization identifier.
      </entry>
     </row>

1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
     <row>
      <entry><structfield>rolconnlimit</structfield></entry>
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
       For roles that can log in, this sets maximum number of concurrent 
       connections this role can make.  -1 means no limit.
      </entry>
     </row>

1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152
     <row>
      <entry><structfield>rolpassword</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Password (possibly encrypted); NULL if none</entry>
     </row>

     <row>
      <entry><structfield>rolvaliduntil</structfield></entry>
      <entry><type>timestamptz</type></entry>
      <entry></entry>
      <entry>Password expiry time (only used for password authentication);
       NULL if no expiration</entry>
     </row>

     <row>
      <entry><structfield>rolconfig</structfield></entry>
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>Session defaults for run-time configuration variables</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>


 <sect1 id="catalog-pg-auth-members">
  <title><structname>pg_auth_members</structname></title>

  <indexterm zone="catalog-pg-auth-members">
   <primary>pg_auth_members</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_auth_members</structname> shows the membership
   relations between roles.  Any non-circular set of relationships is allowed.
  </para>

  <para>
   Because user identities are cluster-wide,
   <structname>pg_auth_members</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_auth_members</structname> per cluster, not
   one per database.
  </para>

  <table>
   <title><structname>pg_auth_members</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>roleid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>ID of a role that has a member</entry>
     </row>

     <row>
      <entry><structfield>member</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>ID of a role that is a member of <structfield>roleid</></entry>
     </row>

     <row>
      <entry><structfield>grantor</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>ID of the role that granted this membership</entry>
     </row>

     <row>
      <entry><structfield>admin_option</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>True if <structfield>member</> may grant membership in
       <structfield>roleid</> to others</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>


1153 1154 1155 1156 1157 1158 1159
 <sect1 id="catalog-pg-autovacuum">
  <title><structname>pg_autovacuum</structname></title>

  <indexterm zone="catalog-pg-autovacuum">
   <primary>pg_autovacuum</primary>
  </indexterm>

1160 1161 1162 1163 1164
  <indexterm zone="catalog-pg-autovacuum">
   <primary>autovacuum</primary>
   <secondary>table-specific configuration</secondary>
  </indexterm>

1165 1166
  <para>
   The catalog <structname>pg_autovacuum</structname> stores optional
1167
   per-relation configuration parameters for <xref linkend="autovacuum" endterm="autovacuum-title">.
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229
   If there is an entry here for a particular relation, the given
   parameters will be used for autovacuuming that table.  If no entry
   is present, the system-wide defaults will be used.
  </para>

  <table>
   <title><structname>pg_autovacuum</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>vacrelid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
      <entry>The table this entry is for</entry>
     </row>

     <row>
      <entry><structfield>enabled</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>If false, this table is never autovacuumed</entry>
     </row>

     <row>
      <entry><structfield>vac_base_thresh</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
      <entry>Minimum number of modified tuples before vacuum</entry>
     </row>

     <row>
      <entry><structfield>vac_scale_factor</structfield></entry>
      <entry><type>float4</type></entry>
      <entry></entry>
      <entry>Multiplier for reltuples to add to
       <structfield>vac_base_thresh</></entry>
     </row>

     <row>
      <entry><structfield>anl_base_thresh</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
      <entry>Minimum number of modified tuples before analyze</entry>
     </row>

     <row>
      <entry><structfield>anl_scale_factor</structfield></entry>
      <entry><type>float4</type></entry>
      <entry></entry>
      <entry>Multiplier for reltuples to add to
       <structfield>anl_base_thresh</></entry>
     </row>
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243

     <row>
      <entry><structfield>vac_cost_delay</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
      <entry>Custom <varname>vacuum_cost_delay</> parameter</entry>
     </row>

     <row>
      <entry><structfield>vac_cost_limit</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
      <entry>Custom <varname>vacuum_cost_limit</> parameter</entry>
     </row>
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
    </tbody>
   </tgroup>
  </table>

  <para>
   The autovacuum daemon will initiate a <command>VACUUM</> operation
   on a particular table when the number of updated or deleted tuples
   exceeds <structfield>vac_base_thresh</structfield> plus
   <structfield>vac_scale_factor</structfield> times the number of
   live tuples currently estimated to be in the relation.
   Similarly, it will initiate an <command>ANALYZE</> operation
   when the number of inserted, updated or deleted tuples
   exceeds <structfield>anl_base_thresh</structfield> plus
   <structfield>anl_scale_factor</structfield> times the number of
   live tuples currently estimated to be in the relation.
  </para>

  <para>
   Any of the numerical fields can contain <literal>-1</> (or indeed
   any negative value) to indicate that the system-wide default should
1264 1265 1266 1267 1268
   be used for this particular value.  Observe that the
   <structfield>vac_cost_delay</> variable inherits its default value from the
   <varname>autovacuum_vacuum_cost_delay</> configuration parameter,
   or from <varname>vacuum_cost_delay</> if the former is set to a negative
   value.  The same applies to <structfield>vac_cost_limit</>.
1269 1270 1271 1272 1273
  </para>

 </sect1>


1274
 <sect1 id="catalog-pg-cast">
1275 1276 1277 1278 1279
  <title><structname>pg_cast</structname></title>

  <indexterm zone="catalog-pg-cast">
   <primary>pg_cast</primary>
  </indexterm>
1280 1281

  <para>
1282
   The catalog <structname>pg_cast</structname> stores data type conversion paths,
1283
   both built-in paths and those defined with <command>CREATE CAST</command>.
1284 1285 1286
  </para>

  <table>
1287
   <title><structfield>pg_cast</> Columns</title>
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
1301
      <entry><structfield>castsource</structfield></entry>
1302
      <entry><type>oid</type></entry>
1303
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1304 1305 1306 1307
      <entry>OID of the source data type</entry>
     </row>

     <row>
1308
      <entry><structfield>casttarget</structfield></entry>
1309
      <entry><type>oid</type></entry>
1310
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1311 1312 1313 1314
      <entry>OID of the target data type</entry>
     </row>

     <row>
1315
      <entry><structfield>castfunc</structfield></entry>
1316
      <entry><type>oid</type></entry>
1317
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
1318
      <entry>
1319
       The OID of the function to use to perform this cast.  Zero is
1320
       stored if the data types are binary compatible (that is, no
1321
       run-time operation is needed to perform the cast).
1322 1323 1324 1325
      </entry>
     </row>

     <row>
1326
      <entry><structfield>castcontext</structfield></entry>
1327
      <entry><type>char</type></entry>
1328
      <entry></entry>
1329 1330 1331
      <entry>
       Indicates what contexts the cast may be invoked in.
       <literal>e</> means only as an explicit cast (using
1332
       <literal>CAST</> or <literal>::</> syntax).
1333 1334 1335 1336 1337
       <literal>a</> means implicitly in assignment
       to a target column, as well as explicitly.
       <literal>i</> means implicitly in expressions, as well as the
       other cases.
      </entry>
1338 1339 1340 1341
     </row>
    </tbody>
   </tgroup>
  </table>
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372

  <para>
   The cast functions listed in <structname>pg_cast</structname> must
   always take the cast source type as their first argument type, and
   return the cast destination type as their result type.  A cast
   function can have up to three arguments.  The second argument,
   if present, must be type <type>integer</>; it receives the type
   modifier associated with the destination type, or <literal>-1</>
   if there is none.  The third argument,
   if present, must be type <type>boolean</>; it receives <literal>true</>
   if the cast is an explicit cast, <literal>false</> otherwise.
  </para>

  <para>
   It is legitimate to create a <structname>pg_cast</structname> entry
   in which the source and target types are the same, if the associated
   function takes more than one argument.  Such entries represent
   <quote>length coercion functions</> that coerce values of the type
   to be legal for a particular type modifier value.  Note however that
   at present there is no support for associating non-default type
   modifiers with user-created data types, and so this facility is only
   of use for the small number of built-in types that have type modifier
   syntax built into the grammar.
  </para>

  <para>
   When a <structname>pg_cast</structname> entry has different source and
   target types and a function that takes more than one argument, it
   represents converting from one type to another and applying a length
   coercion in a single step.  When no such entry is available, coercion
   to a type that uses a type modifier involves two steps, one to
Peter Eisentraut's avatar
Peter Eisentraut committed
1373
   convert between data types and a second to apply the modifier.
1374
  </para>
1375 1376
 </sect1>

1377
 <sect1 id="catalog-pg-class">
1378 1379 1380 1381 1382
  <title><structname>pg_class</structname></title>

  <indexterm zone="catalog-pg-class">
   <primary>pg_class</primary>
  </indexterm>
1383 1384

  <para>
1385
   The catalog <structname>pg_class</structname> catalogs tables and most
1386
   everything else that has columns or is otherwise similar to a
1387
   table.  This includes indexes (but see also
1388
   <structname>pg_index</structname>), sequences, views, composite types,
1389
   and TOAST tables; see <structfield>relkind</>.
1390
   Below, when we mean all of these
1391
   kinds of objects we speak of <quote>relations</quote>.  Not all
1392
   columns are meaningful for all relation types.
1393 1394 1395
  </para>

  <table>
1396
   <title><structname>pg_class</> Columns</title>
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
1410
      <entry><structfield>relname</structfield></entry>
1411 1412 1413 1414 1415
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Name of the table, index, view, etc.</entry>
     </row>

1416
     <row>
1417
      <entry><structfield>relnamespace</structfield></entry>
1418
      <entry><type>oid</type></entry>
1419
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
1420 1421 1422 1423 1424
      <entry>
       The OID of the namespace that contains this relation
      </entry>
     </row>

1425
     <row>
1426
      <entry><structfield>reltype</structfield></entry>
1427
      <entry><type>oid</type></entry>
1428
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1429
      <entry>
Peter Eisentraut's avatar
Peter Eisentraut committed
1430
       The OID of the data type that corresponds to this table's row type,
1431
       if any (zero for indexes, which have no <structname>pg_type</> entry)
1432 1433 1434 1435
      </entry>
     </row>

     <row>
1436
      <entry><structfield>relowner</structfield></entry>
1437 1438
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1439 1440 1441 1442
      <entry>Owner of the relation</entry>
     </row>

     <row>
1443
      <entry><structfield>relam</structfield></entry>
1444
      <entry><type>oid</type></entry>
1445
      <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
1446
      <entry>If this is an index, the access method used (B-tree, hash, etc.)</entry>
1447 1448 1449
     </row>

     <row>
1450
      <entry><structfield>relfilenode</structfield></entry>
1451 1452
      <entry><type>oid</type></entry>
      <entry></entry>
1453
      <entry>Name of the on-disk file of this relation; 0 if none</entry>
1454 1455
     </row>

1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466
     <row>
      <entry><structfield>reltablespace</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
      <entry>
       The tablespace in which this relation is stored.  If zero,
       the database's default tablespace is implied.  (Not meaningful
       if the relation has no on-disk file.)
      </entry>
     </row>

1467
     <row>
1468
      <entry><structfield>relpages</structfield></entry>
1469 1470 1471
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
1472
       Size of the on-disk representation of this table in pages (of size
1473 1474 1475
       <symbol>BLCKSZ</symbol>).
       This is only an estimate used by the planner.
       It is updated by <command>VACUUM</command>,
1476 1477
       <command>ANALYZE</command>, and a few DDL commands
       such as <command>CREATE INDEX</command>.
1478 1479 1480 1481
      </entry>
     </row>

     <row>
1482
      <entry><structfield>reltuples</structfield></entry>
1483
      <entry><type>float4</type></entry>
1484 1485
      <entry></entry>
      <entry>
1486
       Number of rows in the table.
1487 1488
       This is only an estimate used by the planner.
       It is updated by <command>VACUUM</command>,
1489 1490
       <command>ANALYZE</command>, and a few DDL commands
       such as <command>CREATE INDEX</command>.
1491 1492 1493 1494
      </entry>
     </row>

     <row>
1495
      <entry><structfield>reltoastrelid</structfield></entry>
1496
      <entry><type>oid</type></entry>
1497
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1498
      <entry>
1499
       OID of the TOAST table associated with this table, 0 if none.
1500 1501 1502 1503 1504 1505
       The TOAST table stores large attributes <quote>out of
       line</quote> in a secondary table.
      </entry>
     </row>

     <row>
1506
      <entry><structfield>reltoastidxid</structfield></entry>
1507
      <entry><type>oid</type></entry>
1508
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1509 1510 1511
      <entry>
       For a TOAST table, the OID of its index.  0 if not a TOAST table.
      </entry>
1512 1513 1514
     </row>

     <row>
1515
      <entry><structfield>relhasindex</structfield></entry>
1516 1517
      <entry><type>bool</type></entry>
      <entry></entry>
1518 1519 1520 1521
      <entry>
       True if this is a table and it has (or recently had) any
       indexes. This is set by <command>CREATE INDEX</command>, but
       not cleared immediately by <command>DROP INDEX</command>.
1522
       <command>VACUUM</command> clears <structfield>relhasindex</> if it finds the
1523
       table has no indexes.
1524
      </entry>
1525 1526 1527
     </row>

     <row>
1528
      <entry><structfield>relisshared</structfield></entry>
1529 1530
      <entry><type>bool</type></entry>
      <entry></entry>
1531
      <entry>True if this table is shared across all databases in the
1532 1533
      cluster.  Only certain system catalogs (such as
      <structname>pg_database</structname>) are shared.</entry>
1534 1535 1536
     </row>

     <row>
1537
      <entry><structfield>relkind</structfield></entry>
1538 1539 1540
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
1541 1542
       <literal>r</> = ordinary table, <literal>i</> = index,
       <literal>S</> = sequence, <literal>v</> = view, <literal>c</> =
1543
       composite type, <literal>t</> = TOAST
1544
       table
1545 1546 1547 1548
      </entry>
     </row>

     <row>
1549
      <entry><structfield>relnatts</structfield></entry>
1550 1551 1552
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>
1553 1554
       Number of user columns in the relation (system columns not
       counted).  There must be this many corresponding entries in
1555
       <structname>pg_attribute</structname>.  See also
1556
       <literal>pg_attribute.attnum</literal>.
1557 1558 1559 1560
      </entry>
     </row>

     <row>
1561
      <entry><structfield>relchecks</structfield></entry>
1562 1563 1564 1565
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>
       Number of check constraints on the table; see
1566
       <structname>pg_constraint</structname> catalog
1567 1568 1569 1570
      </entry>
     </row>

     <row>
1571
      <entry><structfield>reltriggers</structfield></entry>
1572 1573 1574 1575 1576 1577 1578 1579 1580
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>
       Number of triggers on the table; see
       <structname>pg_trigger</structname> catalog
      </entry>
     </row>

     <row>
1581
      <entry><structfield>relukeys</structfield></entry>
1582 1583
      <entry><type>int2</type></entry>
      <entry></entry>
1584
      <entry>Unused  (<emphasis>not</emphasis> the number of unique keys)</entry>
1585 1586 1587
     </row>

     <row>
1588
      <entry><structfield>relfkeys</structfield></entry>
1589 1590
      <entry><type>int2</type></entry>
      <entry></entry>
1591
      <entry>Unused  (<emphasis>not</emphasis> the number of foreign keys on the table)</entry>
1592 1593 1594
     </row>

     <row>
1595
      <entry><structfield>relrefs</structfield></entry>
1596 1597
      <entry><type>int2</type></entry>
      <entry></entry>
1598
      <entry>Unused</entry>
1599 1600 1601
     </row>

     <row>
1602
      <entry><structfield>relhasoids</structfield></entry>
1603 1604 1605
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
1606
       True if we generate an OID for each row of the relation
1607
      </entry>
1608 1609 1610
     </row>

     <row>
1611
      <entry><structfield>relhaspkey</structfield></entry>
1612 1613 1614
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
1615
       True if the table has (or once had) a primary key
1616 1617 1618 1619
      </entry>
     </row>

     <row>
1620
      <entry><structfield>relhasrules</structfield></entry>
1621 1622
      <entry><type>bool</type></entry>
      <entry></entry>
1623
      <entry>True if table has rules; see
1624
       <structname>pg_rewrite</structname> catalog
1625
      </entry>
1626 1627 1628
     </row>

     <row>
1629
      <entry><structfield>relhassubclass</structfield></entry>
1630 1631
      <entry><type>bool</type></entry>
      <entry></entry>
1632
      <entry>True if table has (or once had) any inheritance children</entry>
1633 1634
     </row>

1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658
     <row>
      <entry><structfield>relminxid</structfield></entry>
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
       The minimum transaction ID present in all rows in this table.  This
       value is used to determine the database-global
       <structname>pg_database</>.<structfield>datminxid</> value.
      </entry>
     </row>

     <row>
      <entry><structfield>relvacuumxid</structfield></entry>
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
       The transaction ID that was used as cleaning point as of the last vacuum
       operation.  All rows inserted, updated or deleted in this table by
       transactions whose IDs are below this one have been marked as known good
       or deleted.  This is used to determine the database-global
       <structname>pg_database</>.<structfield>datvacuumxid</> value.
      </entry>
     </row>

1659
     <row>
1660
      <entry><structfield>relacl</structfield></entry>
1661 1662 1663
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
      <entry>
1664 1665 1666
       Access privileges; see
       <xref linkend="sql-grant" endterm="sql-grant-title"> and
       <xref linkend="sql-revoke" endterm="sql-revoke-title">
1667
       for details
1668 1669
      </entry>
     </row>
1670 1671 1672 1673 1674 1675 1676 1677 1678

     <row>
      <entry><structfield>reloptions</structfield></entry>
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>
       Access-method-specific options, as <quote>keyword=value</> strings
      </entry>
     </row>
1679 1680 1681
    </tbody>
   </tgroup>
  </table>
1682
 </sect1>
1683

1684
 <sect1 id="catalog-pg-constraint">
1685 1686 1687 1688 1689
  <title><structname>pg_constraint</structname></title>

  <indexterm zone="catalog-pg-constraint">
   <primary>pg_constraint</primary>
  </indexterm>
1690 1691

  <para>
1692 1693 1694 1695 1696
   The catalog <structname>pg_constraint</structname> stores check, primary key, unique, and foreign
   key constraints on tables.  (Column constraints are not treated
   specially.  Every column constraint is equivalent to some table
   constraint.)  Not-null constraints are represented in the
   <structname>pg_attribute</> catalog.
1697 1698 1699
  </para>

  <para>
1700
   Check constraints on domains are stored here, too.
1701 1702 1703
  </para>

  <table>
1704
   <title><structname>pg_constraint</> Columns</title>
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
1718
      <entry><structfield>conname</structfield></entry>
1719 1720 1721 1722 1723 1724
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Constraint name (not necessarily unique!)</entry>
     </row>

     <row>
1725
      <entry><structfield>connamespace</structfield></entry>
1726
      <entry><type>oid</type></entry>
1727
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
1728 1729 1730 1731 1732 1733
      <entry>
       The OID of the namespace that contains this constraint
      </entry>
     </row>

     <row>
1734
      <entry><structfield>contype</structfield></entry>
1735 1736 1737
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
1738 1739 1740 1741
        <literal>c</> = check constraint,
        <literal>f</> = foreign key constraint,
        <literal>p</> = primary key constraint,
        <literal>u</> = unique constraint
1742 1743 1744 1745
      </entry>
     </row>

     <row>
1746 1747
      <entry><structfield>condeferrable</structfield></entry>
      <entry><type>bool</type></entry>
1748 1749 1750 1751 1752
      <entry></entry>
      <entry>Is the constraint deferrable?</entry>
     </row>

     <row>
1753 1754
      <entry><structfield>condeferred</structfield></entry>
      <entry><type>bool</type></entry>
1755 1756 1757 1758 1759
      <entry></entry>
      <entry>Is the constraint deferred by default?</entry>
     </row>

     <row>
1760
      <entry><structfield>conrelid</structfield></entry>
1761
      <entry><type>oid</type></entry>
1762
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1763 1764 1765 1766
      <entry>The table this constraint is on; 0 if not a table constraint</entry>
     </row>

     <row>
1767
      <entry><structfield>contypid</structfield></entry>
1768
      <entry><type>oid</type></entry>
1769
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
1770 1771 1772 1773
      <entry>The domain this constraint is on; 0 if not a domain constraint</entry>
     </row>

     <row>
1774
      <entry><structfield>confrelid</structfield></entry>
1775
      <entry><type>oid</type></entry>
1776
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1777 1778 1779 1780
      <entry>If a foreign key, the referenced table; else 0</entry>
     </row>

     <row>
1781
      <entry><structfield>confupdtype</structfield></entry>
1782 1783 1784 1785 1786 1787
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>Foreign key update action code</entry>
     </row>

     <row>
1788
      <entry><structfield>confdeltype</structfield></entry>
1789 1790 1791 1792 1793 1794
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>Foreign key deletion action code</entry>
     </row>

     <row>
1795
      <entry><structfield>confmatchtype</structfield></entry>
1796 1797 1798 1799 1800 1801
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>Foreign key match type</entry>
     </row>

     <row>
1802
      <entry><structfield>conkey</structfield></entry>
1803
      <entry><type>int2[]</type></entry>
1804
      <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
1805 1806 1807 1808
      <entry>If a table constraint, list of columns which the constraint constrains</entry>
     </row>

     <row>
1809
      <entry><structfield>confkey</structfield></entry>
1810
      <entry><type>int2[]</type></entry>
1811
      <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
1812 1813 1814 1815
      <entry>If a foreign key, list of the referenced columns</entry>
     </row>

     <row>
1816
      <entry><structfield>conbin</structfield></entry>
1817 1818 1819 1820 1821 1822
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>If a check constraint, an internal representation of the expression</entry>
     </row>

     <row>
1823
      <entry><structfield>consrc</structfield></entry>
1824 1825 1826 1827 1828 1829 1830 1831
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>If a check constraint, a human-readable representation of the expression</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

1832 1833 1834 1835 1836 1837 1838 1839 1840
  <note>
   <para>
    <structfield>consrc</structfield> is not updated when referenced objects
    change; for example, it won't track renaming of columns.  Rather than
    relying on this field, it's best to use <function>pg_get_constraintdef()</>
    to extract the definition of a check constraint.
   </para>
  </note>

1841 1842
  <note>
   <para>
1843 1844 1845
    <literal>pg_class.relchecks</literal> needs to agree with the
    number of check-constraint entries found in this table for the
    given relation.
1846 1847 1848 1849
   </para>
  </note>

 </sect1>
1850

1851
 <sect1 id="catalog-pg-conversion">
1852 1853 1854 1855 1856
  <title><structname>pg_conversion</structname></title>

  <indexterm zone="catalog-pg-conversion">
   <primary>pg_conversion</primary>
  </indexterm>
1857 1858

  <para>
1859 1860 1861 1862
   The catalog <structname>pg_conversion</structname> describes the
   available encoding conversion procedures.  See
   <xref linkend="sql-createconversion" endterm="sql-createconversion-title">
   for more information.
1863 1864 1865
  </para>

  <table>
1866
   <title><structname>pg_conversion</> Columns</title>
1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
1880
      <entry><structfield>conname</structfield></entry>
1881 1882 1883 1884 1885 1886
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Conversion name (unique within a namespace)</entry>
     </row>

     <row>
1887
      <entry><structfield>connamespace</structfield></entry>
1888
      <entry><type>oid</type></entry>
1889
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
1890 1891 1892 1893 1894 1895
      <entry>
       The OID of the namespace that contains this conversion
      </entry>
     </row>

     <row>
1896
      <entry><structfield>conowner</structfield></entry>
1897 1898
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1899
      <entry>Owner of the conversion</entry>
1900 1901 1902
     </row>

     <row>
1903
      <entry><structfield>conforencoding</structfield></entry>
1904 1905
      <entry><type>int4</type></entry>
      <entry></entry>
1906
      <entry>Source encoding ID</entry>
1907 1908 1909
     </row>

     <row>
1910
      <entry><structfield>contoencoding</structfield></entry>
1911 1912
      <entry><type>int4</type></entry>
      <entry></entry>
1913
      <entry>Destination encoding ID</entry>
1914 1915 1916
     </row>

     <row>
1917
      <entry><structfield>conproc</structfield></entry>
1918
      <entry><type>regproc</type></entry>
1919
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
1920 1921 1922 1923
      <entry>Conversion procedure</entry>
     </row>

     <row>
1924 1925
      <entry><structfield>condefault</structfield></entry>
      <entry><type>bool</type></entry>
1926
      <entry></entry>
1927
      <entry>True if this is the default conversion</entry>
1928 1929 1930 1931 1932 1933 1934 1935
     </row>

    </tbody>
   </tgroup>
  </table>

 </sect1>

1936
 <sect1 id="catalog-pg-database">
1937 1938 1939 1940 1941
  <title><structname>pg_database</structname></title>

  <indexterm zone="catalog-pg-database">
   <primary>pg_database</primary>
  </indexterm>
1942 1943

  <para>
1944
   The catalog <structname>pg_database</structname> stores information
1945
   about the available databases.  Databases are created with the
1946 1947
   <command>CREATE DATABASE</command> command.  Consult
   <xref linkend="managing-databases"> for details about the meaning of some of the
1948
   parameters.
1949 1950
  </para>

1951 1952 1953 1954 1955 1956 1957
  <para>
   Unlike most system catalogs, <structname>pg_database</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_database</structname> per cluster, not
   one per database.
  </para>

1958
  <table>
1959
   <title><structname>pg_database</> Columns</title>
1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
1973
      <entry><structfield>datname</structfield></entry>
1974 1975 1976 1977 1978 1979
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Database name</entry>
     </row>

     <row>
1980
      <entry><structfield>datdba</structfield></entry>
1981 1982
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
1983
      <entry>Owner of the database, usually the user who created it</entry>
1984 1985 1986
     </row>

     <row>
1987
      <entry><structfield>encoding</structfield></entry>
1988 1989
      <entry><type>int4</type></entry>
      <entry></entry>
1990 1991 1992
      <entry>Character encoding for this database
          (<function>pg_encoding_to_char()</function> can translate
           this number to the encoding name)</entry>
1993 1994 1995
     </row>

     <row>
1996
      <entry><structfield>datistemplate</structfield></entry>
1997 1998 1999 2000
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       If true then this database can be used in the
2001
       <literal>TEMPLATE</literal> clause of <command>CREATE
2002
       DATABASE</command> to create a new database as a clone of
2003 2004 2005 2006 2007
       this one.
      </entry>
     </row>

     <row>
2008
      <entry><structfield>datallowconn</structfield></entry>
2009 2010 2011 2012
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       If false then no one can connect to this database.  This is
2013
       used to protect the <literal>template0</> database from being altered.
2014 2015 2016
      </entry>
     </row>

2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
     <row>
      <entry><structfield>datconnlimit</structfield></entry>
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
       Sets maximum number of concurrent connections that can be made 
       to this database.  -1 means no limit.
      </entry>
     </row>

2027
     <row>
2028
      <entry><structfield>datlastsysoid</structfield></entry>
2029 2030 2031
      <entry><type>oid</type></entry>
      <entry></entry>
      <entry>
2032
       Last system OID in the database; useful
2033 2034 2035 2036
       particularly to <application>pg_dump</application>
      </entry>
     </row>

2037
     <row>
2038
      <entry><structfield>datvacuumxid</structfield></entry>
2039 2040 2041
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
2042 2043 2044 2045 2046 2047
       The transaction ID that was used as cleaning point as of the last vacuum
       operation.  All rows inserted or deleted by transaction IDs before this one
       have been marked as known good or deleted.  This
       is used to determine when commit-log space can be recycled.
       If InvalidTransactionId, then the minimum is unknown and can be
       determined by scanning <structname>pg_class</>.<structfield>relvacuumxid</>.
2048 2049 2050 2051
      </entry>
     </row>

     <row>
2052
      <entry><structfield>datminxid</structfield></entry>
2053 2054 2055
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
2056
       The minimum transaction ID present in all tables in this database.
2057
       All rows inserted by transaction IDs before this one have been
2058
       relabeled with a permanent (<quote>frozen</>) transaction ID in this
2059 2060 2061 2062
       database.  This is useful to check whether a database must be
       vacuumed soon to avoid transaction ID wrap-around problems.
       If InvalidTransactionId, then the minimum is unknown and can be
       determined by scanning <structname>pg_class</>.<structfield>relminxid</>.
2063 2064 2065
      </entry>
     </row>

2066
     <row>
2067 2068 2069
      <entry><structfield>dattablespace</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
2070
      <entry>
2071 2072 2073 2074 2075
       The default tablespace for the database.
       Within this database, all tables for which
       <structname>pg_class</>.<structfield>reltablespace</> is zero
       will be stored in this tablespace; in particular, all the non-shared
       system catalogs will be there.
2076 2077
      </entry>
     </row>
2078 2079

     <row>
2080
      <entry><structfield>datconfig</structfield></entry>
2081 2082 2083 2084
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>Session defaults for run-time configuration variables</entry>
     </row>
2085 2086

     <row>
2087
      <entry><structfield>datacl</structfield></entry>
2088 2089
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
2090 2091 2092 2093
      <entry>
       Access privileges; see
       <xref linkend="sql-grant" endterm="sql-grant-title"> and
       <xref linkend="sql-revoke" endterm="sql-revoke-title">
2094
       for details
2095
      </entry>
2096
     </row>
2097 2098 2099
    </tbody>
   </tgroup>
  </table>
2100
 </sect1>
2101 2102


2103
 <sect1 id="catalog-pg-depend">
2104 2105 2106 2107 2108
  <title><structname>pg_depend</structname></title>

  <indexterm zone="catalog-pg-depend">
   <primary>pg_depend</primary>
  </indexterm>
2109 2110

  <para>
2111
   The catalog <structname>pg_depend</structname> records the dependency
2112 2113
   relationships between database objects.  This information allows
   <command>DROP</> commands to find which other objects must be dropped
2114
   by <command>DROP CASCADE</> or prevent dropping in the <command>DROP
2115 2116 2117
   RESTRICT</> case.
  </para>

2118 2119 2120 2121 2122 2123
  <para>
   See also <link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link>,
   which performs a similar function for dependencies involving objects
   that are shared across a database cluster.
  </para>

2124
  <table>
2125
   <title><structname>pg_depend</> Columns</title>
2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2139
      <entry><structfield>classid</structfield></entry>
2140
      <entry><type>oid</type></entry>
2141
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2142
      <entry>The OID of the system catalog the dependent object is in</entry>
2143 2144 2145
     </row>

     <row>
2146
      <entry><structfield>objid</structfield></entry>
2147
      <entry><type>oid</type></entry>
2148 2149
      <entry>any OID column</entry>
      <entry>The OID of the specific dependent object</entry>
2150 2151 2152
     </row>

     <row>
2153
      <entry><structfield>objsubid</structfield></entry>
2154
      <entry><type>int4</type></entry>
2155
      <entry></entry>
2156 2157 2158 2159 2160
      <entry>
       For a table column, this is the column number (the
       <structfield>objid</> and <structfield>classid</> refer to the
       table itself).  For all other object types, this column is
       zero.
2161 2162 2163 2164
      </entry>
     </row>

     <row>
2165
      <entry><structfield>refclassid</structfield></entry>
2166
      <entry><type>oid</type></entry>
2167
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2168
      <entry>The OID of the system catalog the referenced object is in</entry>
2169 2170 2171
     </row>

     <row>
2172
      <entry><structfield>refobjid</structfield></entry>
2173
      <entry><type>oid</type></entry>
2174
      <entry>any OID column</entry>
2175
      <entry>The OID of the specific referenced object</entry>
2176 2177 2178
     </row>

     <row>
2179
      <entry><structfield>refobjsubid</structfield></entry>
2180
      <entry><type>int4</type></entry>
2181
      <entry></entry>
2182 2183 2184 2185 2186
      <entry>
       For a table column, this is the column number (the
       <structfield>refobjid</> and <structfield>refclassid</> refer
       to the table itself).  For all other object types, this column
       is zero.
2187 2188 2189 2190
      </entry>
     </row>

     <row>
2191
      <entry><structfield>deptype</structfield></entry>
2192 2193 2194
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
2195
       A code defining the specific semantics of this dependency relationship; see text
2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208
      </entry>
     </row>

    </tbody>
   </tgroup>
  </table>

  <para>
   In all cases, a <structname>pg_depend</structname> entry indicates that the
   referenced object may not be dropped without also dropping the dependent
   object.  However, there are several subflavors identified by
   <structfield>deptype</>:

2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269
   <variablelist>
    <varlistentry>
     <term><symbol>DEPENDENCY_NORMAL</> (<literal>n</>)</term>
     <listitem>
      <para>
       A normal relationship between separately-created objects.  The
       dependent object may be dropped without affecting the
       referenced object.  The referenced object may only be dropped
       by specifying <literal>CASCADE</>, in which case the dependent
       object is dropped, too.  Example: a table column has a normal
       dependency on its data type.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><symbol>DEPENDENCY_AUTO</> (<literal>a</>)</term>
     <listitem>
      <para>
       The dependent object can be dropped separately from the
       referenced object, and should be automatically dropped
       (regardless of <literal>RESTRICT</> or <literal>CASCADE</>
       mode) if the referenced object is dropped.  Example: a named
       constraint on a table is made autodependent on the table, so
       that it will go away if the table is dropped.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><symbol>DEPENDENCY_INTERNAL</> (<literal>i</>)</term>
     <listitem>
      <para>
       The dependent object was created as part of creation of the
       referenced object, and is really just a part of its internal
       implementation.  A <command>DROP</> of the dependent object
       will be disallowed outright (we'll tell the user to issue a
       <command>DROP</> against the referenced object, instead).  A
       <command>DROP</> of the referenced object will be propagated
       through to drop the dependent object whether
       <command>CASCADE</> is specified or not.  Example: a trigger
       that's created to enforce a foreign-key constraint is made
       internally dependent on the constraint's
       <structname>pg_constraint</> entry.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><symbol>DEPENDENCY_PIN</> (<literal>p</>)</term>
     <listitem>
      <para>
       There is no dependent object; this type of entry is a signal
       that the system itself depends on the referenced object, and so
       that object must never be deleted.  Entries of this type are
       created only by <command>initdb</command>.  The columns for the
       dependent object contain zeroes.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
2270 2271 2272 2273 2274 2275 2276

   Other dependency flavors may be needed in future.
  </para>

 </sect1>


2277
 <sect1 id="catalog-pg-description">
2278 2279 2280 2281 2282
  <title><structname>pg_description</structname></title>

  <indexterm zone="catalog-pg-description">
   <primary>pg_description</primary>
  </indexterm>
2283 2284

  <para>
2285 2286
   The catalog <structname>pg_description</> stores optional descriptions
   (comments) for each database object.  Descriptions can be manipulated
2287
   with the <command>COMMENT</command> command and viewed with
2288
   <application>psql</application>'s <literal>\d</literal> commands.
2289
   Descriptions of many built-in system objects are provided in the initial
2290
   contents of <structname>pg_description</structname>.
2291 2292
  </para>

2293 2294 2295 2296 2297 2298
  <para>
   See also <link linkend="catalog-pg-shdescription"><structname>pg_shdescription</structname></link>,
   which performs a similar function for descriptions involving objects that
   are shared across a database cluster.
  </para>

2299
  <table>
2300
   <title><structname>pg_description</> Columns</title>
2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2314
      <entry><structfield>objoid</structfield></entry>
2315
      <entry><type>oid</type></entry>
2316 2317
      <entry>any OID column</entry>
      <entry>The OID of the object this description pertains to</entry>
2318 2319
     </row>

2320
     <row>
2321
      <entry><structfield>classoid</structfield></entry>
2322
      <entry><type>oid</type></entry>
2323
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2324
      <entry>The OID of the system catalog this object appears in</entry>
2325 2326 2327
     </row>

     <row>
2328
      <entry><structfield>objsubid</structfield></entry>
2329 2330
      <entry><type>int4</type></entry>
      <entry></entry>
2331 2332 2333 2334 2335
      <entry>
       For a comment on a table column, this is the column number (the
       <structfield>objoid</> and <structfield>classoid</> refer to
       the table itself).  For all other object types, this column is
       zero.
2336 2337 2338
      </entry>
     </row>

2339
     <row>
2340
      <entry><structfield>description</structfield></entry>
2341 2342
      <entry><type>text</type></entry>
      <entry></entry>
2343
      <entry>Arbitrary text that serves as the description of this object</entry>
2344 2345 2346 2347 2348
     </row>
    </tbody>
   </tgroup>
  </table>

2349
 </sect1>
2350 2351


2352
 <sect1 id="catalog-pg-index">
2353 2354 2355 2356 2357
  <title><structname>pg_index</structname></title>

  <indexterm zone="catalog-pg-index">
   <primary>pg_index</primary>
  </indexterm>
2358 2359

  <para>
2360
   The catalog <structname>pg_index</structname> contains part of the information
2361 2362 2363 2364 2365
   about indexes.  The rest is mostly in
   <structname>pg_class</structname>.
  </para>

  <table>
2366
   <title><structname>pg_index</> Columns</title>
2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2380
      <entry><structfield>indexrelid</structfield></entry>
2381
      <entry><type>oid</type></entry>
2382
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2383
      <entry>The OID of the <structname>pg_class</> entry for this index</entry>
2384 2385 2386
     </row>

     <row>
2387
      <entry><structfield>indrelid</structfield></entry>
2388
      <entry><type>oid</type></entry>
2389
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2390
      <entry>The OID of the <structname>pg_class</> entry for the table this index is for</entry>
2391 2392 2393
     </row>

     <row>
2394 2395
      <entry><structfield>indnatts</structfield></entry>
      <entry><type>int2</type></entry>
2396
      <entry></entry>
2397 2398
      <entry>The number of columns in the index (duplicates
      <literal>pg_class.relnatts</literal>)</entry>
2399 2400 2401
     </row>

     <row>
2402
      <entry><structfield>indisunique</structfield></entry>
2403 2404
      <entry><type>bool</type></entry>
      <entry></entry>
2405
      <entry>If true, this is a unique index</entry>
2406 2407 2408
     </row>

     <row>
2409
      <entry><structfield>indisprimary</structfield></entry>
2410 2411
      <entry><type>bool</type></entry>
      <entry></entry>
2412
      <entry>If true, this index represents the primary key of the table.
2413
      (<structfield>indisunique</> should always be true when this is true.)</entry>
2414 2415 2416
     </row>

     <row>
2417 2418
      <entry><structfield>indisclustered</structfield></entry>
      <entry><type>bool</type></entry>
2419
      <entry></entry>
2420
      <entry>If true, the table was last clustered on this index</entry>
2421 2422
     </row>

2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433
     <row>
      <entry><structfield>indisvalid</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>If true, the index is currently valid for queries.
       False means the index is possibly incomplete: it must still be
       inserted into by INSERT/UPDATE operations, but it cannot safely be
       used for queries, and if it is unique, the uniqueness shouldn't be
       relied on either.</entry>
     </row>

2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458
     <row>
      <entry><structfield>indkey</structfield></entry>
      <entry><type>int2vector</type></entry>
      <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
      <entry>
       This is an array of <structfield>indnatts</structfield> values that
       indicate which table columns this index indexes.  For example a value
       of <literal>1 3</literal> would mean that the first and the third table
       columns make up the index key.  A zero in this array indicates that the
       corresponding index attribute is an expression over the table columns,
       rather than a simple column reference.
      </entry>
     </row>

     <row>
      <entry><structfield>indclass</structfield></entry>
      <entry><type>oidvector</type></entry>
      <entry><literal><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.oid</literal></entry>
      <entry>
       For each column in the index key this contains the OID of
       the operator class to use.  See
       <structname>pg_opclass</structname> for details.
      </entry>
     </row>

2459 2460 2461 2462 2463 2464 2465
     <row>
      <entry><structfield>indexprs</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Expression trees (in <function>nodeToString()</function> representation)
      for index attributes that are not simple column references.  This is a
      list with one element for each zero entry in <structfield>indkey</>.
2466
      NULL if all index attributes are simple references.</entry>
2467 2468 2469
     </row>

     <row>
2470
      <entry><structfield>indpred</structfield></entry>
2471 2472
      <entry><type>text</type></entry>
      <entry></entry>
2473
      <entry>Expression tree (in <function>nodeToString()</function> representation)
2474
      for partial index predicate.  NULL if not a partial index.</entry>
2475 2476 2477 2478 2479
     </row>
    </tbody>
   </tgroup>
  </table>

2480
 </sect1>
2481 2482


2483
 <sect1 id="catalog-pg-inherits">
2484 2485 2486 2487 2488
  <title><structname>pg_inherits</structname></title>

  <indexterm zone="catalog-pg-inherits">
   <primary>pg_inherits</primary>
  </indexterm>
2489 2490

  <para>
2491
   The catalog <structname>pg_inherits</> records information about
2492 2493 2494
   table inheritance hierarchies.  There is one entry for each direct
   child table in the database.  (Indirect inheritance can be determined
   by following chains of entries.)
2495 2496 2497
  </para>

  <table>
2498
   <title><structname>pg_inherits</> Columns</title>
2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2512
      <entry><structfield>inhrelid</structfield></entry>
2513
      <entry><type>oid</type></entry>
2514
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2515
      <entry>
2516
       The OID of the child table
2517 2518 2519 2520
      </entry>
     </row>

     <row>
2521
      <entry><structfield>inhparent</structfield></entry>
2522
      <entry><type>oid</type></entry>
2523
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
2524
      <entry>
2525
       The OID of the parent table
2526 2527 2528 2529
      </entry>
     </row>

     <row>
2530
      <entry><structfield>inhseqno</structfield></entry>
2531 2532 2533
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
2534
       If there is more than one direct parent for a child table (multiple
2535 2536 2537 2538 2539 2540 2541 2542
       inheritance), this number tells the order in which the
       inherited columns are to be arranged.  The count starts at 1.
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

2543
 </sect1>
2544 2545


2546
 <sect1 id="catalog-pg-language">
2547 2548 2549 2550 2551
  <title><structname>pg_language</structname></title>

  <indexterm zone="catalog-pg-language">
   <primary>pg_language</primary>
  </indexterm>
2552 2553

  <para>
2554
   The catalog <structname>pg_language</structname> registers
2555
   languages in which you can write functions or stored procedures.
2556 2557
   See <xref linkend="sql-createlanguage" endterm="sql-createlanguage-title">
   and <xref linkend="xplang"> for more information about language handlers.
2558 2559 2560
  </para>

  <table>
2561
   <title><structname>pg_language</> Columns</title>
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2575
      <entry><structfield>lanname</structfield></entry>
2576 2577
      <entry><type>name</type></entry>
      <entry></entry>
2578
      <entry>Name of the language</entry>
2579 2580 2581
     </row>

     <row>
2582
      <entry><structfield>lanispl</structfield></entry>
2583 2584 2585
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
2586 2587 2588 2589 2590
       This is false for internal languages (such as
       <acronym>SQL</acronym>) and true for user-defined languages.
       Currently, <application>pg_dump</application> still uses this
       to determine which languages need to be dumped, but this may be
       replaced by a different mechanism sometime.
2591 2592 2593 2594
      </entry>
     </row>

     <row>
2595
      <entry><structfield>lanpltrusted</structfield></entry>
2596 2597 2598
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
2599 2600 2601 2602
       True if this is a trusted language, which means that it is believed
       not to grant access to anything outside the normal SQL execution
       environment.  Only superusers may create functions in untrusted
       languages.
2603 2604 2605 2606
      </entry>
     </row>

     <row>
2607
      <entry><structfield>lanplcallfoid</structfield></entry>
2608
      <entry><type>oid</type></entry>
2609
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2610
      <entry>
2611
       For noninternal languages this references the language
2612 2613 2614 2615 2616 2617
       handler, which is a special function that is responsible for
       executing all functions that are written in the particular
       language.
      </entry>
     </row>

2618
     <row>
2619
      <entry><structfield>lanvalidator</structfield></entry>
2620
      <entry><type>oid</type></entry>
2621
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
2622 2623 2624
      <entry>
       This references a language validator function that is responsible
       for checking the syntax and validity of new functions when they
2625
       are created.  Zero if no validator is provided.
2626 2627 2628
      </entry>
     </row>

2629
     <row>
2630
      <entry><structfield>lanacl</structfield></entry>
2631 2632
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
2633 2634 2635 2636
      <entry>
       Access privileges; see
       <xref linkend="sql-grant" endterm="sql-grant-title"> and
       <xref linkend="sql-revoke" endterm="sql-revoke-title">
2637
       for details
2638
      </entry>
2639
     </row>
2640 2641 2642 2643
    </tbody>
   </tgroup>
  </table>

2644
 </sect1>
2645 2646


2647
 <sect1 id="catalog-pg-largeobject">
2648 2649 2650 2651 2652
  <title><structname>pg_largeobject</structname></title>

  <indexterm zone="catalog-pg-largeobject">
   <primary>pg_largeobject</primary>
  </indexterm>
2653 2654

  <para>
2655
   The catalog <structname>pg_largeobject</structname> holds the data making up
2656 2657 2658 2659
   <quote>large objects</quote>.  A large object is identified by an
   OID assigned when it is created.  Each large object is broken into
   segments or <quote>pages</> small enough to be conveniently stored as rows
   in <structname>pg_largeobject</structname>.
2660 2661
   The amount of data per page is defined to be <literal>LOBLKSIZE</> (which is currently
   <literal>BLCKSZ/4</>, or typically 2 kB).
2662 2663 2664
  </para>

  <table>
2665
   <title><structname>pg_largeobject</> Columns</title>
2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2679
      <entry><structfield>loid</structfield></entry>
2680 2681 2682 2683 2684 2685
      <entry><type>oid</type></entry>
      <entry></entry>
      <entry>Identifier of the large object that includes this page</entry>
     </row>

     <row>
2686
      <entry><structfield>pageno</structfield></entry>
2687 2688 2689 2690 2691 2692 2693
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>Page number of this page within its large object
      (counting from zero)</entry>
     </row>

     <row>
2694
      <entry><structfield>data</structfield></entry>
2695 2696 2697 2698
      <entry><type>bytea</type></entry>
      <entry></entry>
      <entry>
       Actual data stored in the large object.
2699
       This will never be more than <symbol>LOBLKSIZE</> bytes and may be less.
2700 2701 2702 2703 2704 2705 2706 2707 2708
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   Each row of <structname>pg_largeobject</structname> holds data
   for one page of a large object, beginning at
2709
   byte offset (<literal>pageno * LOBLKSIZE</>) within the object.  The implementation
2710
   allows sparse storage: pages may be missing, and may be shorter than
2711
   <literal>LOBLKSIZE</> bytes even if they are not the last page of the object.
2712 2713 2714
   Missing regions within a large object read as zeroes.
  </para>

2715
 </sect1>
2716 2717


2718
 <sect1 id="catalog-pg-listener">
2719 2720 2721 2722 2723
  <title><structname>pg_listener</structname></title>

  <indexterm zone="catalog-pg-listener">
   <primary>pg_listener</primary>
  </indexterm>
2724 2725

  <para>
2726 2727 2728 2729
   The catalog <structname>pg_listener</structname> supports the
   <xref linkend="sql-listen" endterm="sql-listen-title"> and
   <xref linkend="sql-notify" endterm="sql-notify-title">
   commands.  A listener creates an entry in
2730 2731 2732 2733 2734 2735 2736 2737
   <structname>pg_listener</structname> for each notification name
   it is listening for.  A notifier scans <structname>pg_listener</structname>
   and updates each matching entry to show that a notification has occurred.
   The notifier also sends a signal (using the PID recorded in the table)
   to awaken the listener from sleep.
  </para>

  <table>
2738
   <title><structname>pg_listener</> Columns</title>
2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2752
      <entry><structfield>relname</structfield></entry>
2753 2754 2755
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Notify condition name.  (The name need not match any actual
2756
      relation in the database; the name <structfield>relname</> is historical.)
2757 2758 2759 2760
      </entry>
     </row>

     <row>
2761
      <entry><structfield>listenerpid</structfield></entry>
2762 2763
      <entry><type>int4</type></entry>
      <entry></entry>
2764
      <entry>PID of the server process that created this entry</entry>
2765 2766 2767
     </row>

     <row>
2768
      <entry><structfield>notification</structfield></entry>
2769 2770 2771 2772
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
       Zero if no event is pending for this listener.  If an event is
2773
       pending, the PID of the server process that sent the notification.
2774 2775 2776 2777 2778 2779
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

2780
 </sect1>
2781 2782


2783
 <sect1 id="catalog-pg-namespace">
2784 2785 2786 2787 2788
  <title><structname>pg_namespace</structname></title>

  <indexterm zone="catalog-pg-namespace">
   <primary>pg_namespace</primary>
  </indexterm>
2789 2790

  <para>
2791 2792 2793
   The catalog <structname>pg_namespace</> stores namespaces.
   A namespace is the structure underlying SQL schemas: each namespace
   can have a separate collection of relations, types, etc. without name
2794 2795 2796 2797
   conflicts.
  </para>

  <table>
2798
   <title><structname>pg_namespace</> Columns</title>
2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2812
      <entry><structfield>nspname</structfield></entry>
2813 2814 2815 2816 2817 2818
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Name of the namespace</entry>
     </row>

     <row>
2819
      <entry><structfield>nspowner</structfield></entry>
2820 2821
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2822
      <entry>Owner of the namespace</entry>
2823 2824 2825
     </row>

     <row>
2826
      <entry><structfield>nspacl</structfield></entry>
2827 2828
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
2829 2830 2831 2832
      <entry>
       Access privileges; see
       <xref linkend="sql-grant" endterm="sql-grant-title"> and
       <xref linkend="sql-revoke" endterm="sql-revoke-title">
2833
       for details
2834
      </entry>
2835 2836 2837 2838 2839 2840 2841 2842
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>


2843
 <sect1 id="catalog-pg-opclass">
2844 2845 2846 2847 2848
  <title><structname>pg_opclass</structname></title>

  <indexterm zone="catalog-pg-opclass">
   <primary>pg_opclass</primary>
  </indexterm>
2849 2850

  <para>
2851
   The catalog <structname>pg_opclass</structname> defines
2852
   index access method operator classes.  Each operator class defines
2853
   semantics for index columns of a particular data type and a particular
2854
   index access method.  Note that there can be multiple operator classes
2855
   for a given data type/access method combination, thus supporting multiple
2856 2857 2858 2859
   behaviors.
  </para>

  <para>
2860
   Operator classes are described at length in <xref linkend="xindex">.
2861 2862 2863
  </para>

  <table>
2864
   <title><structname>pg_opclass</> Columns</title>
2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>

     <row>
2878
      <entry><structfield>opcamid</structfield></entry>
2879
      <entry><type>oid</type></entry>
2880
      <entry><literal><link linkend="catalog-pg-am"><structname>pg_am</structname></link>.oid</literal></entry>
2881
      <entry>Index access method operator class is for</entry>
2882 2883 2884
     </row>

     <row>
2885
      <entry><structfield>opcname</structfield></entry>
2886 2887
      <entry><type>name</type></entry>
      <entry></entry>
2888
      <entry>Name of this operator class</entry>
2889 2890 2891
     </row>

     <row>
2892
      <entry><structfield>opcnamespace</structfield></entry>
2893
      <entry><type>oid</type></entry>
2894
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
2895
      <entry>Namespace of this operator class</entry>
2896 2897 2898
     </row>

     <row>
2899
      <entry><structfield>opcowner</structfield></entry>
2900 2901 2902
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>Owner of the operator class</entry>
2903 2904 2905
     </row>

     <row>
2906
      <entry><structfield>opcintype</structfield></entry>
2907
      <entry><type>oid</type></entry>
2908
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
2909
      <entry>Data type that the operator class indexes</entry>
2910 2911 2912
     </row>

     <row>
2913
      <entry><structfield>opcdefault</structfield></entry>
2914 2915
      <entry><type>bool</type></entry>
      <entry></entry>
2916
      <entry>True if this operator class is the default for <structfield>opcintype</></entry>
2917 2918 2919
     </row>

     <row>
2920
      <entry><structfield>opckeytype</structfield></entry>
2921
      <entry><type>oid</type></entry>
2922
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
2923
      <entry>Type of data stored in index, or zero if same as <structfield>opcintype</></entry>
2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934
     </row>

    </tbody>
   </tgroup>
  </table>

  <para>
   The majority of the information defining an operator class is actually
   not in its <structname>pg_opclass</structname> row, but in the associated
   rows in <structname>pg_amop</structname> and
   <structname>pg_amproc</structname>.  Those rows are considered to be
2935
   part of the operator class definition &mdash; this is not unlike the way
2936
   that a relation is defined by a single <structname>pg_class</structname>
2937
   row plus associated rows in <structname>pg_attribute</structname> and
2938 2939 2940 2941 2942 2943
   other tables.
  </para>

 </sect1>


2944
 <sect1 id="catalog-pg-operator">
2945 2946 2947 2948 2949
  <title><structname>pg_operator</structname></title>

  <indexterm zone="catalog-pg-operator">
   <primary>pg_operator</primary>
  </indexterm>
2950 2951

  <para>
2952 2953 2954
   The catalog <structname>pg_operator</> stores information about operators.
   See <xref linkend="sql-createoperator" endterm="sql-createoperator-title">
   and <xref linkend="xoper"> for more information.
2955 2956 2957
  </para>

  <table>
2958
   <title><structname>pg_operator</> Columns</title>
2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
2972
      <entry><structfield>oprname</structfield></entry>
2973 2974 2975 2976 2977
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Name of the operator</entry>
     </row>

2978
     <row>
2979
      <entry><structfield>oprnamespace</structfield></entry>
2980
      <entry><type>oid</type></entry>
2981
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
2982 2983 2984 2985 2986
      <entry>
       The OID of the namespace that contains this operator
      </entry>
     </row>

2987
     <row>
2988
      <entry><structfield>oprowner</structfield></entry>
2989 2990
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2991
      <entry>Owner of the operator</entry>
2992 2993 2994
     </row>

     <row>
2995
      <entry><structfield>oprkind</structfield></entry>
2996 2997 2998
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
2999 3000
       <literal>b</> = infix (<quote>both</quote>), <literal>l</> = prefix
       (<quote>left</quote>), <literal>r</> = postfix (<quote>right</quote>)
3001 3002 3003 3004
      </entry>
     </row>

     <row>
3005
      <entry><structfield>oprcanhash</structfield></entry>
3006 3007
      <entry><type>bool</type></entry>
      <entry></entry>
3008
      <entry>This operator supports hash joins</entry>
3009 3010 3011
     </row>

     <row>
3012
      <entry><structfield>oprleft</structfield></entry>
3013
      <entry><type>oid</type></entry>
3014
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3015 3016 3017 3018
      <entry>Type of the left operand</entry>
     </row>

     <row>
3019
      <entry><structfield>oprright</structfield></entry>
3020
      <entry><type>oid</type></entry>
3021
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3022 3023 3024 3025
      <entry>Type of the right operand</entry>
     </row>

     <row>
3026
      <entry><structfield>oprresult</structfield></entry>
3027
      <entry><type>oid</type></entry>
3028
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3029 3030 3031 3032
      <entry>Type of the result</entry>
     </row>

     <row>
3033
      <entry><structfield>oprcom</structfield></entry>
3034
      <entry><type>oid</type></entry>
3035
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3036 3037 3038 3039
      <entry>Commutator of this operator, if any</entry>
     </row>

     <row>
3040
      <entry><structfield>oprnegate</structfield></entry>
3041
      <entry><type>oid</type></entry>
3042
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
Bruce Momjian's avatar
Bruce Momjian committed
3043
      <entry>Negator of this operator, if any</entry>
3044 3045 3046
     </row>

     <row>
3047
      <entry><structfield>oprlsortop</structfield></entry>
3048
      <entry><type>oid</type></entry>
3049
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3050 3051
      <entry>
       If this operator supports merge joins, the operator that sorts
3052
       the type of the left-hand operand (<literal>L&lt;L</>)
3053 3054 3055 3056
      </entry>
     </row>

     <row>
3057
      <entry><structfield>oprrsortop</structfield></entry>
3058
      <entry><type>oid</type></entry>
3059
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3060 3061
      <entry>
       If this operator supports merge joins, the operator that sorts
3062 3063 3064 3065 3066
       the type of the right-hand operand (<literal>R&lt;R</>)
      </entry>
     </row>

     <row>
3067
      <entry><structfield>oprltcmpop</structfield></entry>
3068
      <entry><type>oid</type></entry>
3069
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3070 3071 3072 3073 3074 3075 3076
      <entry>
       If this operator supports merge joins, the less-than operator that
       compares the left and right operand types (<literal>L&lt;R</>)
      </entry>
     </row>

     <row>
3077
      <entry><structfield>oprgtcmpop</structfield></entry>
3078
      <entry><type>oid</type></entry>
3079
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3080 3081 3082
      <entry>
       If this operator supports merge joins, the greater-than operator that
       compares the left and right operand types (<literal>L&gt;R</>)
3083 3084 3085 3086
      </entry>
     </row>

     <row>
3087
      <entry><structfield>oprcode</structfield></entry>
3088
      <entry><type>regproc</type></entry>
3089
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3090 3091 3092 3093
      <entry>Function that implements this operator</entry>
     </row>

     <row>
3094
      <entry><structfield>oprrest</structfield></entry>
3095
      <entry><type>regproc</type></entry>
3096
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3097 3098 3099 3100
      <entry>Restriction selectivity estimation function for this operator</entry>
     </row>

     <row>
3101
      <entry><structfield>oprjoin</structfield></entry>
3102
      <entry><type>regproc</type></entry>
3103
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
3104 3105 3106 3107 3108 3109
      <entry>Join selectivity estimation function for this operator</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

3110
  <para>
3111 3112
   Unused column contain zeroes. For example, <structfield>oprleft</structfield>
   is zero for a prefix operator.
3113 3114
  </para>

3115
 </sect1>
3116 3117


3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203
 <sect1 id="catalog-pg-pltemplate">
  <title><structname>pg_pltemplate</structname></title>

  <indexterm zone="catalog-pg-pltemplate">
   <primary>pg_pltemplate</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_pltemplate</structname> stores
   <quote>template</> information for procedural languages.
   A template for a language allows the language to be created in a
   particular database by a simple <command>CREATE LANGUAGE</> command,
   with no need to specify implementation details.
  </para>

  <para>
   Unlike most system catalogs, <structname>pg_pltemplate</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_pltemplate</structname> per cluster, not
   one per database.  This allows the information to be accessible in
   each database as it is needed.
  </para>

  <table>
   <title><structname>pg_pltemplate</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>tmplname</structfield></entry>
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Name of the language this template is for</entry>
     </row>

     <row>
      <entry><structfield>tmpltrusted</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry></entry>
      <entry>True if language is considered trusted</entry>
     </row>

     <row>
      <entry><structfield>tmplhandler</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Name of call handler function</entry>
     </row>

     <row>
      <entry><structfield>tmplvalidator</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Name of validator function, or NULL if none</entry>
     </row>

     <row>
      <entry><structfield>tmpllibrary</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Path of shared library that implements language</entry>
     </row>

     <row>
      <entry><structfield>tmplacl</structfield></entry>
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
      <entry>Access privileges for template (not yet used)</entry>
     </row>

    </tbody>
   </tgroup>
  </table>

  <para>
   There are not currently any commands that manipulate procedural language
   templates; to change the built-in information, a superuser must modify
3204 3205 3206 3207
   the table using ordinary <command>INSERT</command>, <command>DELETE</command>,
   or <command>UPDATE</command> commands.  It is likely that a future
   release of <productname>PostgreSQL</productname> will offer
   commands to change the entries in a cleaner fashion.
3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218
  </para>

  <para>
   When implemented, the <structfield>tmplacl</structfield> field will provide
   access control for the template itself (i.e., the right to create a
   language using it), not for the languages created from the template.
  </para>

 </sect1>


3219
 <sect1 id="catalog-pg-proc">
3220 3221 3222 3223 3224
  <title><structname>pg_proc</structname></title>

  <indexterm zone="catalog-pg-proc">
   <primary>pg_proc</primary>
  </indexterm>
3225 3226

  <para>
3227
   The catalog <structname>pg_proc</> stores information about functions (or procedures).
3228 3229
   See <xref linkend="sql-createfunction" endterm="sql-createfunction-title">
   and <xref linkend="xfunc"> for more information.
3230 3231
  </para>

3232 3233 3234
  <para>
   The table contains data for aggregate functions as well as plain functions.
   If <structfield>proisagg</structfield> is true, there should be a matching
3235
   row in <structfield>pg_aggregate</structfield>.
3236 3237
  </para>

3238
  <table>
3239
   <title><structname>pg_proc</> Columns</title>
3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
3253
      <entry><structfield>proname</structfield></entry>
3254 3255 3256 3257 3258
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Name of the function</entry>
     </row>

3259
     <row>
3260
      <entry><structfield>pronamespace</structfield></entry>
3261
      <entry><type>oid</type></entry>
3262
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
3263 3264 3265 3266 3267
      <entry>
       The OID of the namespace that contains this function
      </entry>
     </row>

3268
     <row>
3269
      <entry><structfield>proowner</structfield></entry>
3270 3271
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3272
      <entry>Owner of the function</entry>
3273 3274 3275
     </row>

     <row>
3276
      <entry><structfield>prolang</structfield></entry>
3277
      <entry><type>oid</type></entry>
3278
      <entry><literal><link linkend="catalog-pg-language"><structname>pg_language</structname></link>.oid</literal></entry>
3279 3280 3281 3282
      <entry>Implementation language or call interface of this function</entry>
     </row>

     <row>
3283
      <entry><structfield>proisagg</structfield></entry>
3284 3285
      <entry><type>bool</type></entry>
      <entry></entry>
3286
      <entry>Function is an aggregate function</entry>
3287 3288 3289
     </row>

     <row>
3290
      <entry><structfield>prosecdef</structfield></entry>
3291 3292
      <entry><type>bool</type></entry>
      <entry></entry>
3293 3294
      <entry>Function is a security definer (i.e., a <quote>setuid</>
      function)</entry>
3295 3296 3297
     </row>

     <row>
3298
      <entry><structfield>proisstrict</structfield></entry>
3299 3300 3301 3302 3303 3304 3305 3306 3307 3308
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       Function returns null if any call argument is null.  In that
       case the function won't actually be called at all.  Functions
       that are not <quote>strict</quote> must be prepared to handle
       null inputs.
      </entry>
     </row>

3309
     <row>
3310
      <entry><structfield>proretset</structfield></entry>
3311 3312
      <entry><type>bool</type></entry>
      <entry></entry>
3313
      <entry>Function returns a set (i.e., multiple values of the specified
3314 3315 3316
      data type)</entry>
     </row>

3317
     <row>
3318
      <entry><structfield>provolatile</structfield></entry>
3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
       <structfield>provolatile</structfield> tells whether the function's
       result depends only on its input arguments, or is affected by outside
       factors.
       It is <literal>i</literal> for <quote>immutable</> functions,
       which always deliver the same result for the same inputs.
       It is <literal>s</literal> for <quote>stable</> functions,
       whose results (for fixed inputs) do not change within a scan.
       It is <literal>v</literal> for <quote>volatile</> functions,
       whose results may change at any time.  (Use <literal>v</literal> also
       for functions with side-effects, so that calls to them cannot get
       optimized away.)
      </entry>
     </row>

3336
     <row>
3337
      <entry><structfield>pronargs</structfield></entry>
3338 3339 3340 3341 3342 3343
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>Number of arguments</entry>
     </row>

     <row>
3344
      <entry><structfield>prorettype</structfield></entry>
3345
      <entry><type>oid</type></entry>
3346
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3347
      <entry>Data type of the return value</entry>
3348 3349 3350
     </row>

     <row>
3351
      <entry><structfield>proargtypes</structfield></entry>
3352
      <entry><type>oidvector</type></entry>
3353
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375
      <entry>
       An array with the data types of the function arguments.  This includes
       only input arguments (including INOUT arguments), and thus represents
       the call signature of the function.
      </entry>
     </row>

     <row>
      <entry><structfield>proallargtypes</structfield></entry>
      <entry><type>oid[]</type></entry>
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
      <entry>
       An array with the data types of the function arguments.  This includes
       all arguments (including OUT and INOUT arguments); however, if all the
       arguments are IN arguments, this field will be null.
       Note that subscripting is 1-based, whereas for historical reasons
       <structfield>proargtypes</> is subscripted from 0.
      </entry>
     </row>

     <row>
      <entry><structfield>proargmodes</structfield></entry>
3376
      <entry><type>char[]</type></entry>
3377 3378 3379 3380 3381 3382 3383 3384 3385 3386
      <entry></entry>
      <entry>
        An array with the modes of the function arguments, encoded as
        <literal>i</literal> for IN arguments,
        <literal>o</literal> for OUT arguments,
        <literal>b</literal> for INOUT arguments.
        If all the arguments are IN arguments, this field will be null.
        Note that subscripts correspond to positions of
        <structfield>proallargtypes</> not <structfield>proargtypes</>.
      </entry>
3387 3388
     </row>

3389 3390 3391 3392 3393 3394 3395
     <row>
      <entry><structfield>proargnames</structfield></entry>
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>
        An array with the names of the function arguments.
        Arguments without a name are set to empty strings in the array.
3396 3397 3398
        If none of the arguments have a name, this field will be null.
        Note that subscripts correspond to positions of
        <structfield>proallargtypes</> not <structfield>proargtypes</>.
3399 3400 3401
      </entry>
     </row>

3402
     <row>
3403
      <entry><structfield>prosrc</structfield></entry>
3404 3405 3406 3407 3408 3409
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>
       This tells the function handler how to invoke the function.  It
       might be the actual source code of the function for interpreted
       languages, a link symbol, a file name, or just about anything
3410
       else, depending on the implementation language/call convention.
3411 3412 3413 3414
      </entry>
     </row>

     <row>
3415
      <entry><structfield>probin</structfield></entry>
3416 3417
      <entry><type>bytea</type></entry>
      <entry></entry>
3418 3419 3420
      <entry>Additional information about how to invoke the function.
      Again, the interpretation is language-specific.
      </entry>
3421
     </row>
3422 3423

     <row>
3424
      <entry><structfield>proacl</structfield></entry>
3425 3426
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
3427 3428 3429 3430
      <entry>
       Access privileges; see
       <xref linkend="sql-grant" endterm="sql-grant-title"> and
       <xref linkend="sql-revoke" endterm="sql-revoke-title">
3431
       for details
3432
      </entry>
3433
     </row>
3434 3435 3436 3437
    </tbody>
   </tgroup>
  </table>

3438
  <para>
3439
   For compiled functions, both built-in and dynamically loaded,
3440
   <structfield>prosrc</structfield> contains the function's C-language
3441
   name (link symbol).  For all other currently-known language types,
3442 3443 3444 3445
   <structfield>prosrc</structfield> contains the function's source
   text.  <structfield>probin</structfield> is unused except for
   dynamically-loaded C functions, for which it gives the name of the
   shared library file containing the function.
3446 3447
  </para>

3448
 </sect1>
3449

3450
 <sect1 id="catalog-pg-rewrite">
3451 3452 3453 3454 3455
  <title><structname>pg_rewrite</structname></title>

  <indexterm zone="catalog-pg-rewrite">
   <primary>pg_rewrite</primary>
  </indexterm>
3456 3457

  <para>
3458
   The catalog <structname>pg_rewrite</structname> stores rewrite rules for tables and views.
3459 3460 3461
  </para>

  <table>
3462
   <title><structname>pg_rewrite</> Columns</title>
3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
3476
      <entry><structfield>rulename</structfield></entry>
3477 3478 3479 3480 3481 3482
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Rule name</entry>
     </row>

     <row>
3483
      <entry><structfield>ev_class</structfield></entry>
3484
      <entry><type>oid</type></entry>
3485
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3486 3487 3488 3489
      <entry>The table this rule is for</entry>
     </row>

     <row>
3490
      <entry><structfield>ev_attr</structfield></entry>
3491 3492 3493 3494 3495 3496
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>The column this rule is for (currently, always zero to
      indicate the whole table)</entry>
     </row>

3497
     <row>
3498
      <entry><structfield>ev_type</structfield></entry>
3499 3500
      <entry><type>char</type></entry>
      <entry></entry>
3501 3502 3503 3504 3505
      <entry>
       Event type that the rule is for: 1 = <command>SELECT</>, 2 =
       <command>UPDATE</>, 3 = <command>INSERT</>, 4 =
       <command>DELETE</>
      </entry>
3506 3507
     </row>

3508
     <row>
3509
      <entry><structfield>is_instead</structfield></entry>
3510 3511
      <entry><type>bool</type></entry>
      <entry></entry>
3512
      <entry>True if the rule is an <literal>INSTEAD</literal> rule</entry>
3513 3514 3515
     </row>

     <row>
3516
      <entry><structfield>ev_qual</structfield></entry>
3517 3518
      <entry><type>text</type></entry>
      <entry></entry>
3519 3520 3521 3522 3523
      <entry>
       Expression tree (in the form of a
       <function>nodeToString()</function> representation) for the
       rule's qualifying condition
      </entry>
3524 3525 3526
     </row>

     <row>
3527
      <entry><structfield>ev_action</structfield></entry>
3528 3529
      <entry><type>text</type></entry>
      <entry></entry>
3530 3531 3532 3533 3534
      <entry>
       Query tree (in the form of a
       <function>nodeToString()</function> representation) for the
       rule's action
      </entry>
3535 3536 3537 3538 3539 3540 3541
     </row>
    </tbody>
   </tgroup>
  </table>

  <note>
   <para>
3542
    <literal>pg_class.relhasrules</literal>
3543 3544 3545 3546
    must be true if a table has any rules in this catalog.
   </para>
  </note>

3547
 </sect1>
3548 3549


3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633
 <sect1 id="catalog-pg-shdepend">
  <title><structname>pg_shdepend</structname></title>

  <indexterm zone="catalog-pg-shdepend">
   <primary>pg_shdepend</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_shdepend</structname> records the
   dependency relationships between database objects and shared objects,
   such as roles.  This information allows
   <productname>PostgreSQL</productname> to ensure that those objects are
   unreferenced before attempting to delete them.
  </para>

  <para>
   See also <link linkend="catalog-pg-depend"><structname>pg_depend</structname></link>,
   which performs a similar function for dependencies involving objects
   within a single database.
  </para>

  <para>
   Unlike most system catalogs, <structname>pg_shdepend</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_shdepend</structname> per cluster, not
   one per database.
  </para>

  <table>
   <title><structname>pg_shdepend</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>dbid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
      <entry>The OID of the database the dependent object is in,
       or zero for a shared object</entry>
     </row>

     <row>
      <entry><structfield>classid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
      <entry>The OID of the system catalog the dependent object is in</entry>
     </row>

     <row>
      <entry><structfield>objid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry>any OID column</entry>
      <entry>The OID of the specific dependent object</entry>
     </row>

     <row>
      <entry><structfield>refclassid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
      <entry>The OID of the system catalog the referenced object is in
       (must be a shared catalog)</entry>
     </row>

     <row>
      <entry><structfield>refobjid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry>any OID column</entry>
      <entry>The OID of the specific referenced object</entry>
     </row>

     <row>
      <entry><structfield>deptype</structfield></entry>
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
3634
       A code defining the specific semantics of this dependency relationship; see text
3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691
      </entry>
     </row>

    </tbody>
   </tgroup>
  </table>

  <para>
   In all cases, a <structname>pg_shdepend</structname> entry indicates that
   the referenced object may not be dropped without also dropping the dependent
   object.  However, there are several subflavors identified by
   <structfield>deptype</>:

   <variablelist>
    <varlistentry>
     <term><symbol>SHARED_DEPENDENCY_OWNER</> (<literal>o</>)</term>
     <listitem>
      <para>
       The referenced object (which must be a role) is the owner of the
       dependent object.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><symbol>SHARED_DEPENDENCY_ACL</> (<literal>a</>)</term>
     <listitem>
      <para>
       The referenced object (which must be a role) is mentioned in the
       ACL (access control list, i.e., privileges list) of the
       dependent object.  (A <symbol>SHARED_DEPENDENCY_ACL</> entry is
       not made for the owner of the object, since the owner will have
       a <symbol>SHARED_DEPENDENCY_OWNER</> entry anyway.)
      </para>
     </listitem>
    </varlistentry>

    <varlistentry>
     <term><symbol>SHARED_DEPENDENCY_PIN</> (<literal>p</>)</term>
     <listitem>
      <para>
       There is no dependent object; this type of entry is a signal
       that the system itself depends on the referenced object, and so
       that object must never be deleted.  Entries of this type are
       created only by <command>initdb</command>.  The columns for the
       dependent object contain zeroes.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>

   Other dependency flavors may be needed in future.  Note in particular
   that the current definition only supports roles as referenced objects.
  </para>

 </sect1>

3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758
 <sect1 id="catalog-pg-shdescription">
  <title><structname>pg_shdescription</structname></title>

  <indexterm zone="catalog-pg-shdescription">
   <primary>pg_shdescription</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_shdescription</structname> stores optional
   descriptions (comments) for shared database objects.  Descriptions can
   be manipulated with the <command>COMMENT</command> command and viewed
   with <application>psql</application>'s <literal>\d</literal> commands.
  </para>

  <para>
   See also <link linkend="catalog-pg-description"><structname>pg_description</structname></link>,
   which performs a similar function for descriptions involving objects
   within a single database.
  </para>

  <para>
   Unlike most system catalogs, <structname>pg_shdescription</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_shdescription</structname> per cluster, not
   one per database.
  </para>

  <table>
   <title><structname>pg_shdescription</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>objoid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry>any OID column</entry>
      <entry>The OID of the object this description pertains to</entry>
     </row>

     <row>
      <entry><structfield>classoid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
      <entry>The OID of the system catalog this object appears in</entry>
     </row>

     <row>
      <entry><structfield>description</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Arbitrary text that servers as the description of this object.</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

3759

3760 3761
 <sect1 id="catalog-pg-statistic">
  <title><structname>pg_statistic</structname></title>
3762

3763 3764
  <indexterm zone="catalog-pg-statistic">
   <primary>pg_statistic</primary>
3765
  </indexterm>
3766 3767

  <para>
3768 3769 3770 3771 3772 3773
   The catalog <structname>pg_statistic</structname> stores statistical data
   about the contents of the database.  Entries are created by
   <command>ANALYZE</command> and subsequently used by the query planner.
   There is one entry for each table column that has been analyzed.
   Note that all the statistical data is inherently approximate,
   even assuming that it is up-to-date.
3774 3775 3776
  </para>

  <para>
3777 3778 3779 3780 3781 3782
   <structname>pg_statistic</structname> also stores statistical data about
   the values of index expressions.  These are described as if they were
   actual data columns; in particular, <structfield>starelid</structfield>
   references the index.  No entry is made for an ordinary non-expression
   index column, however, since it would be redundant with the entry
   for the underlying table column.
3783 3784
  </para>

3785
  <para>
3786 3787 3788 3789 3790 3791 3792 3793 3794
   Since different kinds of statistics may be appropriate for different
   kinds of data, <structname>pg_statistic</structname> is designed not
   to assume very much about what sort of statistics it stores.  Only
   extremely general statistics (such as nullness) are given dedicated
   columns in <structname>pg_statistic</structname>.  Everything else
   is stored in <quote>slots</quote>, which are groups of associated columns
   whose content is identified by a code number in one of the slot's columns.
   For more information see
   <filename>src/include/catalog/pg_statistic.h</filename>.
3795 3796
  </para>

3797 3798 3799 3800 3801
  <para>
   <structname>pg_statistic</structname> should not be readable by the
   public, since even statistical information about a table's contents
   may be considered sensitive.  (Example: minimum and maximum values
   of a salary column might be quite interesting.)
3802 3803
   <link linkend="view-pg-stats"><structname>pg_stats</structname></link>
   is a publicly readable view on
3804 3805 3806 3807
   <structname>pg_statistic</structname> that only exposes information
   about those tables that are readable by the current user.
  </para>

3808
  <table>
3809
   <title><structname>pg_statistic</> Columns</title>
3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
3823
      <entry><structfield>starelid</structfield></entry>
3824
      <entry><type>oid</type></entry>
3825
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3826
      <entry>The table or index that the described column belongs to</entry>
3827 3828 3829
     </row>

     <row>
3830
      <entry><structfield>staattnum</structfield></entry>
3831
      <entry><type>int2</type></entry>
3832
      <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
3833 3834 3835 3836
      <entry>The number of the described column</entry>
     </row>

     <row>
3837
      <entry><structfield>stanullfrac</structfield></entry>
3838 3839
      <entry><type>float4</type></entry>
      <entry></entry>
3840
      <entry>The fraction of the column's entries that are null</entry>
3841 3842 3843
     </row>

     <row>
3844
      <entry><structfield>stawidth</structfield></entry>
3845 3846
      <entry><type>int4</type></entry>
      <entry></entry>
3847
      <entry>The average stored width, in bytes, of nonnull entries</entry>
3848 3849 3850
     </row>

     <row>
3851
      <entry><structfield>stadistinct</structfield></entry>
3852 3853
      <entry><type>float4</type></entry>
      <entry></entry>
3854
      <entry>The number of distinct nonnull data values in the column.
3855 3856 3857
      A value greater than zero is the actual number of distinct values.
      A value less than zero is the negative of a fraction of the number
      of rows in the table (for example, a column in which values appear about
3858
      twice on the average could be represented by <structfield>stadistinct</> = -0.5).
3859 3860 3861 3862 3863
      A zero value means the number of distinct values is unknown.
      </entry>
     </row>

     <row>
3864
      <entry><structfield>stakind<replaceable>N</></structfield></entry>
3865 3866
      <entry><type>int2</type></entry>
      <entry></entry>
3867 3868 3869 3870
      <entry>
       A code number indicating the kind of statistics stored in the
       <replaceable>N</>th <quote>slot</quote> of the
       <structname>pg_statistic</structname> row.
3871 3872 3873 3874
      </entry>
     </row>

     <row>
3875
      <entry><structfield>staop<replaceable>N</></structfield></entry>
3876
      <entry><type>oid</type></entry>
3877
      <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
3878 3879 3880 3881 3882
      <entry>
       An operator used to derive the statistics stored in the
       <replaceable>N</>th <quote>slot</quote>.  For example, a
       histogram slot would show the <literal>&lt;</literal> operator
       that defines the sort order of the data.
3883 3884 3885 3886
      </entry>
     </row>

     <row>
3887
      <entry><structfield>stanumbers<replaceable>N</></structfield></entry>
3888 3889
      <entry><type>float4[]</type></entry>
      <entry></entry>
3890 3891
      <entry>
       Numerical statistics of the appropriate kind for the
3892 3893
       <replaceable>N</>th <quote>slot</quote>, or NULL if the slot
       kind does not involve numerical values
3894 3895 3896 3897
      </entry>
     </row>

     <row>
3898
      <entry><structfield>stavalues<replaceable>N</></structfield></entry>
3899
      <entry><type>anyarray</type></entry>
3900
      <entry></entry>
3901 3902
      <entry>
       Column data values of the appropriate kind for the
3903
       <replaceable>N</>th <quote>slot</quote>, or NULL if the slot
3904 3905 3906 3907
       kind does not store any data values.  Each array's element
       values are actually of the specific column's data type, so there
       is no way to define these columns' type more specifically than
       <type>anyarray</>.
3908 3909 3910 3911 3912 3913
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

3914
 </sect1>
3915 3916


3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959
 <sect1 id="catalog-pg-tablespace">
  <title><structname>pg_tablespace</structname></title>

  <indexterm zone="catalog-pg-tablespace">
   <primary>pg_tablespace</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_tablespace</structname> stores information
   about the available tablespaces.  Tables can be placed in particular
   tablespaces to aid administration of disk layout.
  </para>

  <para>
   Unlike most system catalogs, <structname>pg_tablespace</structname>
   is shared across all databases of a cluster: there is only one
   copy of <structname>pg_tablespace</structname> per cluster, not
   one per database.
  </para>

  <table>
   <title><structname>pg_tablespace</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>spcname</structfield></entry>
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Tablespace name</entry>
     </row>

     <row>
      <entry><structfield>spcowner</structfield></entry>
3960 3961
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975
      <entry>Owner of the tablespace, usually the user who created it</entry>
     </row>

     <row>
      <entry><structfield>spclocation</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Location (directory path) of the tablespace</entry>
     </row>

     <row>
      <entry><structfield>spcacl</structfield></entry>
      <entry><type>aclitem[]</type></entry>
      <entry></entry>
3976 3977 3978 3979
      <entry>
       Access privileges; see
       <xref linkend="sql-grant" endterm="sql-grant-title"> and
       <xref linkend="sql-revoke" endterm="sql-revoke-title">
3980
       for details
3981
      </entry>
3982 3983 3984 3985 3986 3987 3988
     </row>
    </tbody>
   </tgroup>
  </table>
 </sect1>


3989
 <sect1 id="catalog-pg-trigger">
3990 3991 3992 3993 3994
  <title><structname>pg_trigger</structname></title>

  <indexterm zone="catalog-pg-trigger">
   <primary>pg_trigger</primary>
  </indexterm>
3995 3996

  <para>
3997 3998 3999
   The catalog <structname>pg_trigger</structname> stores triggers on tables.
   See <xref linkend="sql-createtrigger" endterm="sql-createtrigger-title">
   for more information.
4000 4001 4002
  </para>

  <table>
4003
   <title><structname>pg_trigger</> Columns</title>
4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
4017
      <entry><structfield>tgrelid</structfield></entry>
4018
      <entry><type>oid</type></entry>
4019
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4020 4021 4022 4023
      <entry>The table this trigger is on</entry>
     </row>

     <row>
4024
      <entry><structfield>tgname</structfield></entry>
4025 4026
      <entry><type>name</type></entry>
      <entry></entry>
4027
      <entry>Trigger name (must be unique among triggers of same table)</entry>
4028 4029 4030
     </row>

     <row>
4031
      <entry><structfield>tgfoid</structfield></entry>
4032
      <entry><type>oid</type></entry>
4033
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4034 4035 4036 4037
      <entry>The function to be called</entry>
     </row>

     <row>
4038
      <entry><structfield>tgtype</structfield></entry>
4039 4040
      <entry><type>int2</type></entry>
      <entry></entry>
4041
      <entry>Bit mask identifying trigger conditions</entry>
4042 4043 4044
     </row>

     <row>
4045
      <entry><structfield>tgenabled</structfield></entry>
4046 4047
      <entry><type>bool</type></entry>
      <entry></entry>
4048
      <entry>True if trigger is enabled</entry>
4049 4050 4051
     </row>

     <row>
4052
      <entry><structfield>tgisconstraint</structfield></entry>
4053 4054
      <entry><type>bool</type></entry>
      <entry></entry>
4055
      <entry>True if trigger implements a referential integrity constraint</entry>
4056 4057 4058
     </row>

     <row>
4059
      <entry><structfield>tgconstrname</structfield></entry>
4060 4061
      <entry><type>name</type></entry>
      <entry></entry>
4062
      <entry>Referential integrity constraint name</entry>
4063 4064 4065
     </row>

     <row>
4066
      <entry><structfield>tgconstrrelid</structfield></entry>
4067
      <entry><type>oid</type></entry>
4068
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4069
      <entry>The table referenced by an referential integrity constraint</entry>
4070 4071 4072
     </row>

     <row>
4073
      <entry><structfield>tgdeferrable</structfield></entry>
4074 4075 4076 4077 4078 4079
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>True if deferrable</entry>
     </row>

     <row>
4080
      <entry><structfield>tginitdeferred</structfield></entry>
4081 4082 4083 4084 4085 4086
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>True if initially deferred</entry>
     </row>

     <row>
4087
      <entry><structfield>tgnargs</structfield></entry>
4088 4089 4090 4091 4092 4093
      <entry><type>int2</type></entry>
      <entry></entry>
      <entry>Number of argument strings passed to trigger function</entry>
     </row>

     <row>
4094
      <entry><structfield>tgattr</structfield></entry>
4095 4096 4097 4098 4099 4100
      <entry><type>int2vector</type></entry>
      <entry></entry>
      <entry>Currently unused</entry>
     </row>

     <row>
4101
      <entry><structfield>tgargs</structfield></entry>
4102 4103
      <entry><type>bytea</type></entry>
      <entry></entry>
4104
      <entry>Argument strings to pass to trigger, each NULL-terminated</entry>
4105 4106 4107 4108 4109 4110 4111
     </row>
    </tbody>
   </tgroup>
  </table>

  <note>
   <para>
4112 4113
    <literal>pg_class.reltriggers</literal> needs to agree with the
    number of triggers found in this table for the given relation.
4114 4115 4116
   </para>
  </note>

4117
 </sect1>
4118 4119


4120
 <sect1 id="catalog-pg-type">
4121 4122 4123 4124 4125
  <title><structname>pg_type</structname></title>

  <indexterm zone="catalog-pg-type">
   <primary>pg_type</primary>
  </indexterm>
4126

4127
  <para>
4128 4129 4130 4131 4132
   The catalog <structname>pg_type</structname> stores information about data
   types.  Base types (scalar types) are created with
   <xref linkend="sql-createtype" endterm="sql-createtype-title">, and
   domains with
   <xref linkend="sql-createdomain" endterm="sql-createdomain-title">.
4133
   A composite type is automatically created for each table in the database, to
Tom Lane's avatar
Tom Lane committed
4134
   represent the row structure of the table.  It is also possible to create
4135
   composite types with <command>CREATE TYPE AS</command>.
4136 4137
  </para>

4138
  <table>
4139
   <title><structname>pg_type</> Columns</title>
4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
4153
      <entry><structfield>typname</structfield></entry>
4154 4155 4156 4157 4158
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Data type name</entry>
     </row>

4159
     <row>
4160
      <entry><structfield>typnamespace</structfield></entry>
4161
      <entry><type>oid</type></entry>
4162
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
4163 4164 4165 4166 4167
      <entry>
       The OID of the namespace that contains this type
      </entry>
     </row>

4168
     <row>
4169
      <entry><structfield>typowner</structfield></entry>
4170 4171
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4172
      <entry>Owner of the type</entry>
4173 4174 4175
     </row>

     <row>
4176
      <entry><structfield>typlen</structfield></entry>
4177 4178
      <entry><type>int2</type></entry>
      <entry></entry>
4179 4180 4181 4182 4183 4184 4185
      <entry>
       For a fixed-size type, <structfield>typlen</structfield> is the number
       of bytes in the internal representation of the type.  But for a
       variable-length type, <structfield>typlen</structfield> is negative.
       -1 indicates a <quote>varlena</> type (one that has a length word),
       -2 indicates a null-terminated C string.
      </entry>
4186 4187 4188
     </row>

     <row>
4189
      <entry><structfield>typbyval</structfield></entry>
4190 4191 4192 4193 4194
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       <structfield>typbyval</structfield> determines whether internal
       routines pass a value of this type by value or by reference.
4195 4196 4197
       <structfield>typbyval</structfield> had better be false if
       <structfield>typlen</structfield> is not 1, 2, or 4 (or 8 on machines
       where Datum is 8 bytes).
4198 4199 4200 4201 4202 4203 4204 4205
       Variable-length types are always passed by reference. Note that
       <structfield>typbyval</structfield> can be false even if the
       length would allow pass-by-value; this is currently true for
       type <type>float4</type>, for example.
      </entry>
     </row>

     <row>
4206
      <entry><structfield>typtype</structfield></entry>
4207 4208 4209 4210
      <entry><type>char</type></entry>
      <entry></entry>
      <entry>
       <structfield>typtype</structfield> is <literal>b</literal> for
4211
       a base type, <literal>c</literal> for a composite type (e.g., a
4212 4213 4214 4215
       table's row type), <literal>d</literal> for a domain, or
       <literal>p</literal> for a pseudo-type.  See also
       <structfield>typrelid</structfield> and
       <structfield>typbasetype</structfield>.
4216 4217 4218 4219
      </entry>
     </row>

     <row>
4220
      <entry><structfield>typisdefined</structfield></entry>
4221 4222
      <entry><type>bool</type></entry>
      <entry></entry>
4223 4224 4225 4226 4227
      <entry>
       True if the type is defined, false if this is a placeholder
       entry for a not-yet-defined type.  When
       <structfield>typisdefined</structfield> is false, nothing
       except the type name, namespace, and OID can be relied on.
4228
      </entry>
4229 4230 4231
     </row>

     <row>
4232
      <entry><structfield>typdelim</structfield></entry>
4233 4234
      <entry><type>char</type></entry>
      <entry></entry>
4235 4236
      <entry>Character that separates two values of this type when parsing
      array input.  Note that the delimiter is associated with the array
4237
      element data type, not the array data type.</entry>
4238 4239 4240
     </row>

     <row>
4241
      <entry><structfield>typrelid</structfield></entry>
4242
      <entry><type>oid</type></entry>
4243
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
4244
      <entry>
4245
       If this is a composite type (see
4246
       <structfield>typtype</structfield>), then this column points to
4247 4248 4249 4250 4251
       the <structname>pg_class</structname> entry that defines the
       corresponding table.  (For a free-standing composite type, the
       <structname>pg_class</structname> entry doesn't really represent
       a table, but it is needed anyway for the type's
       <structname>pg_attribute</structname> entries to link to.)
4252
       Zero for non-composite types.
4253 4254 4255 4256
      </entry>
     </row>

     <row>
4257
      <entry><structfield>typelem</structfield></entry>
4258
      <entry><type>oid</type></entry>
4259
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
4260 4261 4262 4263
      <entry>
       If <structfield>typelem</structfield> is not 0 then it
       identifies another row in <structname>pg_type</structname>.
       The current type can then be subscripted like an array yielding
4264 4265 4266 4267 4268
       values of type <structfield>typelem</structfield>.  A
       <quote>true</quote> array type is variable length
       (<structfield>typlen</structfield> = -1),
       but some fixed-length (<structfield>typlen</structfield> &gt; 0) types
       also have nonzero <structfield>typelem</structfield>, for example
4269
       <type>name</type> and <type>point</type>.
4270
       If a fixed-length type has a <structfield>typelem</structfield> then
4271
       its internal representation must be some number of values of the
4272
       <structfield>typelem</structfield> data type with no other data.
4273 4274
       Variable-length array types have a header defined by the array
       subroutines.
4275 4276 4277 4278
      </entry>
     </row>

     <row>
4279
      <entry><structfield>typinput</structfield></entry>
4280
      <entry><type>regproc</type></entry>
4281
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4282
      <entry>Input conversion function (text format)</entry>
4283 4284 4285
     </row>

     <row>
4286
      <entry><structfield>typoutput</structfield></entry>
4287
      <entry><type>regproc</type></entry>
4288
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4289 4290 4291 4292 4293 4294
      <entry>Output conversion function (text format)</entry>
     </row>

     <row>
      <entry><structfield>typreceive</structfield></entry>
      <entry><type>regproc</type></entry>
4295
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4296 4297 4298 4299 4300 4301
      <entry>Input conversion function (binary format), or 0 if none</entry>
     </row>

     <row>
      <entry><structfield>typsend</structfield></entry>
      <entry><type>regproc</type></entry>
4302
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4303
      <entry>Output conversion function (binary format), or 0 if none</entry>
4304 4305
     </row>

4306 4307 4308 4309 4310 4311 4312
     <row>
      <entry><structfield>typanalyze</structfield></entry>
      <entry><type>regproc</type></entry>
      <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
      <entry>Custom ANALYZE function, or 0 to use the standard function</entry>
     </row>

4313
     <row>
4314
      <entry><structfield>typalign</structfield></entry>
4315 4316 4317 4318 4319 4320 4321
      <entry><type>char</type></entry>
      <entry></entry>
      <entry><para>

       <structfield>typalign</structfield> is the alignment required
       when storing a value of this type.  It applies to storage on
       disk as well as most representations of the value inside
4322
       <productname>PostgreSQL</>.
4323
       When multiple values are stored consecutively, such
4324 4325 4326 4327 4328 4329 4330 4331
       as in the representation of a complete row on disk, padding is
       inserted before a datum of this type so that it begins on the
       specified boundary.  The alignment reference is the beginning
       of the first datum in the sequence.
      </para><para>
       Possible values are:
       <itemizedlist>
        <listitem>
4332
         <para><literal>c</> = <type>char</type> alignment, i.e., no alignment needed.</para>
4333 4334
        </listitem>
        <listitem>
4335
         <para><literal>s</> = <type>short</type> alignment (2 bytes on most machines).</para>
4336 4337
        </listitem>
        <listitem>
4338
         <para><literal>i</> = <type>int</type> alignment (4 bytes on most machines).</para>
4339 4340
        </listitem>
        <listitem>
4341
         <para><literal>d</> = <type>double</type> alignment (8 bytes on many machines, but by no means all).</para>
4342 4343 4344 4345 4346 4347
        </listitem>
       </itemizedlist>
      </para><note>
       <para>
        For types used in system tables, it is critical that the size
        and alignment defined in <structname>pg_type</structname>
4348
        agree with the way that the compiler will lay out the column in
4349
        a structure representing a table row.
4350 4351 4352 4353 4354
       </para>
      </note></entry>
     </row>

     <row>
4355
      <entry><structfield>typstorage</structfield></entry>
4356 4357 4358
      <entry><type>char</type></entry>
      <entry></entry>
      <entry><para>
4359
       <structfield>typstorage</structfield> tells for varlena
4360 4361 4362 4363 4364 4365
       types (those with <structfield>typlen</structfield> = -1) if
       the type is prepared for toasting and what the default strategy
       for attributes of this type should be.
       Possible values are
       <itemizedlist>
        <listitem>
4366
         <para><literal>p</>: Value must always be stored plain.</para>
4367 4368 4369
        </listitem>
        <listitem>
         <para>
4370
          <literal>e</>: Value can be stored in a <quote>secondary</quote>
4371
          relation (if relation has one, see
4372
          <literal>pg_class.reltoastrelid</literal>).
4373 4374 4375
         </para>
        </listitem>
        <listitem>
4376
         <para><literal>m</>: Value can be stored compressed inline.</para>
4377 4378
        </listitem>
        <listitem>
4379
         <para><literal>x</>: Value can be stored compressed inline or stored in <quote>secondary</quote> storage.</para>
4380 4381
        </listitem>
       </itemizedlist>
4382 4383
       Note that <literal>m</> columns can also be moved out to secondary
       storage, but only as a last resort (<literal>e</> and <literal>x</> columns are
4384 4385 4386 4387
       moved first).
      </para></entry>
     </row>

4388
     <row>
4389
      <entry><structfield>typnotnull</structfield></entry>
Tom Lane's avatar
Tom Lane committed
4390
      <entry><type>bool</type></entry>
4391 4392
      <entry></entry>
      <entry><para>
4393 4394
       <structfield>typnotnull</structfield> represents a not-null
       constraint on a type.  Used for domains only.
4395 4396 4397
      </para></entry>
     </row>

Tom Lane's avatar
Tom Lane committed
4398
     <row>
4399
      <entry><structfield>typbasetype</structfield></entry>
Tom Lane's avatar
Tom Lane committed
4400
      <entry><type>oid</type></entry>
4401
      <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
Tom Lane's avatar
Tom Lane committed
4402
      <entry><para>
4403
       If this is a domain (see <structfield>typtype</structfield>),
Tom Lane's avatar
Tom Lane committed
4404
       then <structfield>typbasetype</structfield> identifies
4405
       the type that this one is based on.  Zero if not a domain.
Tom Lane's avatar
Tom Lane committed
4406 4407
      </para></entry>
     </row>
4408 4409

     <row>
4410
      <entry><structfield>typtypmod</structfield></entry>
Tom Lane's avatar
Tom Lane committed
4411
      <entry><type>int4</type></entry>
4412 4413
      <entry></entry>
      <entry><para>
4414
       Domains use <structfield>typtypmod</structfield> to record the <literal>typmod</>
4415
       to be applied to their base type (-1 if base type does not use a
4416
       <literal>typmod</>).  -1 if this type is not a domain.
4417
      </para></entry>
Tom Lane's avatar
Tom Lane committed
4418 4419 4420
     </row>

     <row>
4421
      <entry><structfield>typndims</structfield></entry>
Tom Lane's avatar
Tom Lane committed
4422 4423 4424 4425
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry><para>
       <structfield>typndims</structfield> is the number of array dimensions
4426 4427
       for a domain that is an array (that is, <structfield>typbasetype</> is an array type;
       the domain's <structfield>typelem</> will match the base type's <structfield>typelem</structfield>).
4428
       Zero for types other than array domains.
4429 4430 4431 4432
       </para></entry>
     </row>

     <row>
4433
      <entry><structfield>typdefaultbin</structfield></entry>
4434 4435 4436
      <entry><type>text</type></entry>
      <entry></entry>
      <entry><para>
4437 4438
       If <structfield>typdefaultbin</> is not null, it is the <function>nodeToString()</function>
       representation of a default expression for the type.  This is
Tom Lane's avatar
Tom Lane committed
4439
       only used for domains.
4440 4441 4442
      </para></entry>
     </row>

4443
     <row>
4444
      <entry><structfield>typdefault</structfield></entry>
4445 4446
      <entry><type>text</type></entry>
      <entry></entry>
4447
      <entry><para>
4448 4449
       <structfield>typdefault</> is null if the type has no associated
       default value. If <structfield>typdefaultbin</> is not null,
Tom Lane's avatar
Tom Lane committed
4450 4451
       <structfield>typdefault</> must contain a human-readable version of the
       default expression represented by <structfield>typdefaultbin</>.  If
4452
       <structfield>typdefaultbin</> is null and <structfield>typdefault</> is
Tom Lane's avatar
Tom Lane committed
4453 4454 4455
       not, then <structfield>typdefault</> is the external representation of
       the type's default value, which may be fed to the type's input
       converter to produce a constant.
4456
      </para></entry>
4457 4458 4459 4460
     </row>
    </tbody>
   </tgroup>
  </table>
4461
 </sect1>
4462 4463 4464 4465 4466 4467

 <sect1 id="views-overview">
  <title>System Views</title>

  <para>
   In addition to the system catalogs, <productname>PostgreSQL</productname>
4468 4469 4470
   provides a number of built-in views.  Some system views provide convenient
   access to some commonly used queries on the system catalogs.  Other views
   provide access to internal server state.
4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481
  </para>

  <para>
   The information schema (<xref linkend="information-schema">) provides
   an alternative set of views which overlap the functionality of the system
   views.  Since the information schema is SQL-standard whereas the views
   described here are <productname>PostgreSQL</productname>-specific,
   it's usually better to use the information schema if it provides all
   the information you need.
  </para>

4482 4483 4484 4485 4486 4487 4488 4489
  <para>
   <xref linkend="view-table"> lists the system views described here.
   More detailed documentation of each view follows below.
   There are some additional views that provide access to the results of
   the statistics collector; they are described in <xref
   linkend="monitoring-stats-views-table">.
  </para>

4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505
  <para>
   Except where noted, all the views described here are read-only.
  </para>

  <table id="view-table">
   <title>System Views</title>

   <tgroup cols="2">
    <thead>
     <row>
      <entry>View Name</entry>
      <entry>Purpose</entry>
     </row>
    </thead>

    <tbody>
4506 4507 4508 4509 4510
     <row>
      <entry><link linkend="view-pg-cursors"><structname>pg_cursors</structname></link></entry>
      <entry>open cursors</entry>
     </row>

4511 4512 4513 4514 4515
     <row>
      <entry><link linkend="view-pg-group"><structname>pg_group</structname></link></entry>
      <entry>groups of database users</entry>
     </row>

4516 4517 4518 4519 4520 4521 4522 4523 4524 4525
     <row>
      <entry><link linkend="view-pg-indexes"><structname>pg_indexes</structname></link></entry>
      <entry>indexes</entry>
     </row>

     <row>
      <entry><link linkend="view-pg-locks"><structname>pg_locks</structname></link></entry>
      <entry>currently held locks</entry>
     </row>

4526 4527
     <row>
      <entry><link linkend="view-pg-prepared-statements"><structname>pg_prepared_statements</structname></link></entry>
4528
      <entry>prepared statements</entry>
4529 4530
     </row>

4531 4532
     <row>
      <entry><link linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link></entry>
4533
      <entry>prepared transactions</entry>
4534 4535
     </row>

4536 4537 4538 4539 4540
     <row>
      <entry><link linkend="view-pg-roles"><structname>pg_roles</structname></link></entry>
      <entry>database roles</entry>
     </row>

4541 4542 4543 4544 4545 4546 4547 4548 4549 4550
     <row>
      <entry><link linkend="view-pg-rules"><structname>pg_rules</structname></link></entry>
      <entry>rules</entry>
     </row>

     <row>
      <entry><link linkend="view-pg-settings"><structname>pg_settings</structname></link></entry>
      <entry>parameter settings</entry>
     </row>

4551 4552 4553 4554 4555
     <row>
      <entry><link linkend="view-pg-shadow"><structname>pg_shadow</structname></link></entry>
      <entry>database users</entry>
     </row>

4556 4557 4558 4559 4560 4561 4562 4563 4564 4565
     <row>
      <entry><link linkend="view-pg-stats"><structname>pg_stats</structname></link></entry>
      <entry>planner statistics</entry>
     </row>

     <row>
      <entry><link linkend="view-pg-tables"><structname>pg_tables</structname></link></entry>
      <entry>tables</entry>
     </row>

4566
     <row>
4567
      <entry><link linkend="view-pg-timezone-abbrevs"><structname>pg_timezone_abbrevs</structname></link></entry>
4568 4569 4570
      <entry>time zone abbreviations</entry>
     </row>

4571 4572 4573 4574 4575
     <row>
      <entry><link linkend="view-pg-timezone-names"><structname>pg_timezone_names</structname></link></entry>
      <entry>time zone names</entry>
     </row>

4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590
     <row>
      <entry><link linkend="view-pg-user"><structname>pg_user</structname></link></entry>
      <entry>database users</entry>
     </row>

     <row>
      <entry><link linkend="view-pg-views"><structname>pg_views</structname></link></entry>
      <entry>views</entry>
     </row>

    </tbody>
   </tgroup>
  </table>
 </sect1>

4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619
 <sect1 id="view-pg-cursors">
  <title><structname>pg_cursors</structname></title>

  <indexterm zone="view-pg-cursors">
   <primary>pg_cursors</primary>
  </indexterm>

  <para>
   The <structname>pg_cursors</structname> view lists the cursors that
   are currently available. Cursors can be defined in several ways:
   <itemizedlist>
    <listitem>
     <para>
      via the <xref linkend="sql-declare" endterm="sql-declare-title">
      statement in SQL
     </para>
    </listitem>

    <listitem>
     <para>
      via the Bind message in the frontend/backend protocol, as
      described in <xref linkend="protocol-flow-ext-query">
     </para>
    </listitem>

    <listitem>
     <para>
      via the Server Programming Interface (SPI), as described in
      <xref linkend="spi-interface">
Tom Lane's avatar
Tom Lane committed
4620 4621
     </para>
    </listitem>
4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717
   </itemizedlist>

   The <structname>pg_cursors</structname> view displays cursors
   created by any of these means. Cursors only exist for the duration
   of the transaction that defines them, unless they have been
   declared <literal>WITH HOLD</literal>. Therefore non-holdable
   cursors are only present in the view until the end of their
   creating transaction.

   <note>
    <para>
     Cursors are used internally to implement some of the components
     of <productname>PostgreSQL</>, such as procedural languages.
     Therefore, the <structname>pg_cursors</> view may include cursors
     that have not been explicitly created by the user.
    </para>
   </note>
  </para>

  <table>
   <title><structname>pg_cursors</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>name</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>The name of the cursor</entry>
     </row>

     <row>
      <entry><structfield>statement</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>The verbatim query string submitted to declare this cursor</entry>
     </row>

     <row>
      <entry><structfield>is_holdable</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry></entry>
      <entry>
       <literal>true</literal> if the cursor is holdable (that is, it
       can be accessed after the transaction that declared the cursor
       has committed); <literal>false</literal> otherwise
       </entry>
     </row>

     <row>
      <entry><structfield>is_binary</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry></entry>
      <entry>
       <literal>true</literal> if the cursor was declared
       <literal>BINARY</literal>; <literal>false</literal>
       otherwise
       </entry>
     </row>

     <row>
      <entry><structfield>is_scrollable</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry></entry>
      <entry>
       <literal>true</> if the cursor is scrollable (that is, it
       allows rows to be retrieved in a nonsequential manner);
       <literal>false</literal> otherwise
       </entry>
     </row>

     <row>
      <entry><structfield>creation_time</structfield></entry>
      <entry><type>timestamptz</type></entry>
      <entry></entry>
      <entry>The time at which the cursor was declared</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   The <structname>pg_cursors</structname> view is read only.
  </para>

 </sect1>

4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773
 <sect1 id="view-pg-group">
  <title><structname>pg_group</structname></title>

  <indexterm zone="view-pg-group">
   <primary>pg_group</primary>
  </indexterm>

  <para>
   The view <structname>pg_group</structname> exists for backwards
   compatibility: it emulates a catalog that existed in
   <productname>PostgreSQL</productname> before version 8.1.
   It shows the names and members of all roles that are marked as not
   <structfield>rolcanlogin</>, which is an approximation to the set
   of roles that are being used as groups.
  </para>

  <table>
   <title><structname>pg_group</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>groname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
      <entry>Name of the group</entry>
     </row>

     <row>
      <entry><structfield>grosysid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>ID of this group</entry>
     </row>

     <row>
      <entry><structfield>grolist</structfield></entry>
      <entry><type>oid[]</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>An array containing the IDs of the roles in this group</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816
 <sect1 id="view-pg-indexes">
  <title><structname>pg_indexes</structname></title>

  <indexterm zone="view-pg-indexes">
   <primary>pg_indexes</primary>
  </indexterm>

  <para>
   The view <structname>pg_indexes</structname> provides access to
   useful information about each index in the database.
  </para>

  <table>
   <title><structname>pg_indexes</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>schemaname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
      <entry>name of schema containing table and index</entry>
     </row>
     <row>
      <entry><structfield>tablename</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
      <entry>name of table the index is for</entry>
     </row>
     <row>
      <entry><structfield>indexname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
      <entry>name of index</entry>
     </row>
4817 4818 4819 4820 4821 4822
     <row>
      <entry><structfield>tablespace</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.spcname</literal></entry>
      <entry>name of tablespace containing index (NULL if default for database)</entry>
     </row>
4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854
     <row>
      <entry><structfield>indexdef</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>index definition (a reconstructed creation command)</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

 <sect1 id="view-pg-locks">
  <title><structname>pg_locks</structname></title>

  <indexterm zone="view-pg-locks">
   <primary>pg_locks</primary>
  </indexterm>

  <para>
   The view <structname>pg_locks</structname> provides access to
   information about the locks held by open transactions within the
   database server.  See <xref linkend="mvcc"> for more discussion
   of locking.
  </para>

  <para>
   <structname>pg_locks</structname> contains one row per active lockable
   object, requested lock mode, and relevant transaction.  Thus, the same
   lockable object may
   appear many times, if multiple transactions are holding or waiting
   for locks on it.  However, an object that currently has no locks on it
4855
   will not appear at all.
4856 4857 4858
  </para>

  <para>
4859 4860 4861 4862 4863 4864 4865 4866
   There are several distinct types of lockable objects:
   whole relations (e.g., tables), individual pages of relations,
   individual tuples of relations,
   transaction IDs,
   and general database objects (identified by class OID and object OID,
   in the same way as in <structname>pg_description</structname> or
   <structname>pg_depend</structname>).  Also, the right to extend a
   relation is represented as a separate lockable object.
4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882
  </para>

  <table>
   <title><structname>pg_locks</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
4883 4884 4885
      <entry><structfield>locktype</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
4886
      <entry>
4887 4888 4889 4890 4891
       type of the lockable object:
       <literal>relation</>,
       <literal>extend</>,
       <literal>page</>,
       <literal>tuple</>,
4892
       <literal>transactionid</>,
4893 4894
       <literal>object</>, or
       <literal>userlock</>
4895 4896 4897 4898 4899 4900 4901
      </entry>
     </row>
     <row>
      <entry><structfield>database</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
      <entry>
4902
       OID of the database in which the object exists, or
4903
       zero if the object is a shared object, or
4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930
       NULL if the object is a transaction ID
      </entry>
     </row>
     <row>
      <entry><structfield>relation</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
      <entry>
       OID of the relation, or NULL if the object is not
       a relation or part of a relation
      </entry>
     </row>
     <row>
      <entry><structfield>page</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
      <entry>
       page number within the relation, or NULL if the object
       is not a tuple or relation page
      </entry>
     </row>
     <row>
      <entry><structfield>tuple</structfield></entry>
      <entry><type>smallint</type></entry>
      <entry></entry>
      <entry>
       tuple number within the page, or NULL if the object is not a tuple
4931 4932 4933
      </entry>
     </row>
     <row>
4934
      <entry><structfield>transactionid</structfield></entry>
4935 4936 4937
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967
       ID of a transaction, or NULL if the object is not a transaction ID
      </entry>
     </row>
     <row>
      <entry><structfield>classid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
      <entry>
       OID of the system catalog containing the object, or NULL if the
       object is not a general database object
      </entry>
     </row>
     <row>
      <entry><structfield>objid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry>any OID column</entry>
      <entry>
       OID of the object within its system catalog, or NULL if the
       object is not a general database object
      </entry>
     </row>
     <row>
      <entry><structfield>objsubid</structfield></entry>
      <entry><type>smallint</type></entry>
      <entry></entry>
      <entry>
       For a table column, this is the column number (the
       <structfield>classid</> and <structfield>objid</> refer to the
       table itself).  For all other object types, this column is
       zero.  NULL if the object is not a general database object
4968 4969
      </entry>
     </row>
4970 4971 4972 4973 4974
     <row>
      <entry><structfield>transaction</structfield></entry>
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
4975
       ID of the transaction that is holding or awaiting this lock
4976 4977
      </entry>
     </row>
4978 4979 4980 4981
     <row>
      <entry><structfield>pid</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
4982 4983
      <entry>
       Process ID of the server process holding or awaiting this
4984
       lock.  NULL if the lock is held by a prepared transaction.
4985
      </entry>
4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005
     </row>
     <row>
      <entry><structfield>mode</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>name of the lock mode held or desired by this process (see <xref
      linkend="locking-tables">)</entry>
     </row>
     <row>
      <entry><structfield>granted</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry></entry>
      <entry>true if lock is held, false if lock is awaited</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   <structfield>granted</structfield> is true in a row representing a lock
5006
   held by the indicated transaction.  False indicates that this transaction is
5007
   currently waiting to acquire this lock, which implies that some other
5008 5009 5010 5011
   transaction is holding a conflicting lock mode on the same lockable object.
   The waiting transaction will sleep until the other lock is released (or a
   deadlock situation is detected). A single transaction can be waiting to
   acquire at most one lock at a time.
5012 5013 5014 5015 5016 5017 5018 5019 5020 5021
  </para>

  <para>
   Every transaction holds an exclusive lock on its transaction ID for its
   entire duration. If one transaction finds it necessary to wait specifically
   for another transaction, it does so by attempting to acquire share lock on
   the other transaction ID. That will succeed only when the other transaction
   terminates and releases its locks. 
  </para>

5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036
  <para>
   Although tuples are a lockable type of object,
   information about row-level locks is stored on disk, not in memory,
   and therefore row-level locks normally do not appear in this view.
   If a transaction is waiting for a
   row-level lock, it will usually appear in the view as waiting for the
   transaction ID of the current holder of that row lock.
  </para>

  <para>
   If user-defined locks are in use, they are displayed using the columns
   for general database objects.  However, the actual meaning of the lock
   fields in such cases is up to the user.
  </para>

5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062
  <para>
   When the <structname>pg_locks</structname> view is accessed, the
   internal lock manager data structures are momentarily locked, and
   a copy is made for the view to display.  This ensures that the
   view produces a consistent set of results, while not blocking
   normal lock manager operations longer than necessary.  Nonetheless
   there could be some impact on database performance if this view is
   read often.
  </para>

  <para>
   <structname>pg_locks</structname> provides a global view of all locks
   in the database cluster, not only those relevant to the current database.
   Although its <structfield>relation</structfield> column can be joined
   against <structname>pg_class</>.<structfield>oid</> to identify locked
   relations, this will only work correctly for relations in the current
   database (those for which the <structfield>database</structfield> column
   is either the current database's OID or zero).
  </para>

  <para>
   If you have enabled the statistics collector, the
   <structfield>pid</structfield> column can be joined to the
   <structfield>procpid</structfield> column of the
   <structname>pg_stat_activity</structname> view to get more
   information on the session holding or waiting to hold the lock.
5063 5064 5065 5066 5067 5068 5069
   Also, if you are using prepared transactions, the
   <structfield>transaction</> column can be joined to the
   <structfield>transaction</structfield> column of the
   <structname>pg_prepared_xacts</structname> view to get more
   information on prepared transactions that hold locks.
   (A prepared transaction can never be waiting for a lock,
   but it continues to hold the locks it acquired while running.)
5070 5071 5072 5073
  </para>

 </sect1>

5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091
 <sect1 id="view-pg-prepared-statements">
  <title><structname>pg_prepared_statements</structname></title>

  <indexterm zone="view-pg-prepared-statements">
   <primary>pg_prepared_statements</primary>
  </indexterm>

  <para>
   The <structname>pg_prepared_statements</structname> view displays
   all the prepared statements that are available in the current
   session. See <xref linkend="sql-prepare"
   endterm="sql-prepare-title"> for more information about prepared
   statements.
  </para>

  <para>
   <structname>pg_prepared_statements</structname> contains one row
   for each prepared statement. Rows are added to the view when a new
5092 5093 5094
   prepared statement is created and removed when a prepared statement
   is released (for example, via the <xref linkend="sql-deallocate"
   endterm="sql-deallocate-title"> command).
5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114
  </para>

  <table>
   <title><structname>pg_prepared_statements</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>name</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>
5115
       The identifier of the prepared statement
5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135
      </entry>
     </row>
     <row>
      <entry><structfield>statement</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>
       The query string submitted by the client to create this
       prepared statement. For prepared statements created via SQL,
       this is the <command>PREPARE</command> statement submitted by
       the client. For prepared statements created via the
       frontend/backend protocol, this is the text of the prepared
       statement itself.
      </entry>
     </row>
     <row>
      <entry><structfield>prepare_time</structfield></entry>
      <entry><type>timestamptz</type></entry>
      <entry></entry>
      <entry>
5136
       The time at which the prepared statement was created
5137 5138 5139 5140
      </entry>
     </row>
     <row>
      <entry><structfield>parameter_types</structfield></entry>
5141
      <entry><type>regtype[]</type></entry>
5142 5143
      <entry></entry>
      <entry>
5144 5145 5146 5147
       The expected parameter types for the prepared statement in the
       form of an array of <type>regtype</type>. The OID corresponding
       to an element of this array can be obtained by casting the
       <type>regtype</type> value to <type>oid</type>.
5148 5149 5150 5151 5152 5153 5154 5155 5156 5157
      </entry>
     </row>
     <row>
      <entry><structfield>from_sql</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry></entry>
      <entry>
       <literal>true</literal> if the prepared statement was created
       via the <command>PREPARE</command> SQL statement;
       <literal>false</literal> if the statement was prepared via the
5158
       frontend/backend protocol
5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   The <structname>pg_prepared_statements</structname> view is read only.
  </para>
 </sect1>

5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218
 <sect1 id="view-pg-prepared-xacts">
  <title><structname>pg_prepared_xacts</structname></title>

  <indexterm zone="view-pg-prepared-xacts">
   <primary>pg_prepared_xacts</primary>
  </indexterm>

  <para>
   The view <structname>pg_prepared_xacts</structname> displays
   information about transactions that are currently prepared for two-phase
   commit (see <xref linkend="sql-prepare-transaction"
   endterm="sql-prepare-transaction-title"> for details).
  </para>

  <para>
   <structname>pg_prepared_xacts</structname> contains one row per prepared
   transaction.  An entry is removed when the transaction is committed or
   rolled back.
  </para>

  <table>
   <title><structname>pg_prepared_xacts</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>transaction</structfield></entry>
      <entry><type>xid</type></entry>
      <entry></entry>
      <entry>
       Numeric transaction identifier of the prepared transaction
      </entry>
     </row>
     <row>
      <entry><structfield>gid</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>
       Global transaction identifier that was assigned to the transaction
      </entry>
     </row>
5219 5220 5221 5222 5223 5224 5225 5226
     <row>
      <entry><structfield>prepared</structfield></entry>
      <entry><type>timestamp with time zone</type></entry>
      <entry></entry>
      <entry>
       Time at which the transaction was prepared for commit
      </entry>
     </row>
5227 5228 5229
     <row>
      <entry><structfield>owner</structfield></entry>
      <entry><type>name</type></entry>
5230
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258
      <entry>
       Name of the user that executed the transaction
      </entry>
     </row>
     <row>
      <entry><structfield>database</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.datname</literal></entry>
      <entry>
       Name of the database in which the transaction was executed
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   When the <structname>pg_prepared_xacts</structname> view is accessed, the
   internal transaction manager data structures are momentarily locked, and
   a copy is made for the view to display.  This ensures that the
   view produces a consistent set of results, while not blocking
   normal operations longer than necessary.  Nonetheless
   there could be some impact on database performance if this view is
   read often.
  </para>

 </sect1>

5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273
 <sect1 id="view-pg-roles">
  <title><structname>pg_roles</structname></title>

  <indexterm zone="view-pg-roles">
   <primary>pg_roles</primary>
  </indexterm>

  <para>
   The view <structname>pg_roles</structname> provides access to
   information about database roles.  This is simply a publicly
   readable view of 
   <link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>
   that blanks out the password field.
  </para>

5274 5275 5276 5277 5278
  <para>
   This view explicitly exposes the OID column of the underlying table,
   since that is needed to do joins to other catalogs.
  </para>

5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306
  <table>
   <title><structname>pg_roles</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>rolname</structfield></entry>
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>Role name</entry>
     </row>

     <row>
      <entry><structfield>rolsuper</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role has superuser privileges</entry>
     </row>

5307 5308 5309 5310 5311 5312 5313 5314
     <row>
      <entry><structfield>rolinherit</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role automatically inherits privileges of roles it is a
       member of</entry>
     </row>

5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348
     <row>
      <entry><structfield>rolcreaterole</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role may create more roles</entry>
     </row>

     <row>
      <entry><structfield>rolcreatedb</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>Role may create databases</entry>
     </row>

     <row>
      <entry><structfield>rolcatupdate</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       Role may update system catalogs directly.  (Even a superuser may not do
       this unless this column is true.)
      </entry>
     </row>

     <row>
      <entry><structfield>rolcanlogin</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       Role may log in, that is, this role can be given as the initial
       session authorization identifier.
      </entry>
     </row>

5349 5350 5351 5352 5353 5354 5355 5356 5357 5358
     <row>
      <entry><structfield>rolconnlimit</structfield></entry>
      <entry><type>int4</type></entry>
      <entry></entry>
      <entry>
       For roles that can log in, this sets maximum number of concurrent 
       connections this role can make.  -1 means no limit.
      </entry>
     </row>

5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379
     <row>
      <entry><structfield>rolpassword</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Not the password (always reads as <literal>********</>)</entry>
     </row>

     <row>
      <entry><structfield>rolvaliduntil</structfield></entry>
      <entry><type>timestamptz</type></entry>
      <entry></entry>
      <entry>Password expiry time (only used for password authentication);
       NULL if no expiration</entry>
     </row>

     <row>
      <entry><structfield>rolconfig</structfield></entry>
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>Session defaults for run-time configuration variables</entry>
     </row>
5380 5381 5382 5383 5384 5385 5386

     <row>
      <entry><structfield>oid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>ID of role</entry>
     </row>
5387 5388 5389 5390 5391 5392
    </tbody>
   </tgroup>
  </table>

 </sect1>

5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493
 <sect1 id="view-pg-rules">
  <title><structname>pg_rules</structname></title>

  <indexterm zone="view-pg-rules">
   <primary>pg_rules</primary>
  </indexterm>

  <para>
   The view <structname>pg_rules</structname> provides access to
   useful information about query rewrite rules.
  </para>

  <table>
   <title><structname>pg_rules</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>schemaname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
      <entry>name of schema containing table</entry>
     </row>
     <row>
      <entry><structfield>tablename</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
      <entry>name of table the rule is for</entry>
     </row>
     <row>
      <entry><structfield>rulename</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link>.rulename</literal></entry>
      <entry>name of rule</entry>
     </row>
     <row>
      <entry><structfield>definition</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>rule definition (a reconstructed creation command)</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   The <structname>pg_rules</structname> view excludes the ON SELECT rules of
   views; those can be seen in <structname>pg_views</structname>.
  </para>

 </sect1>

 <sect1 id="view-pg-settings">
  <title><structname>pg_settings</structname></title>

  <indexterm zone="view-pg-settings">
   <primary>pg_settings</primary>
  </indexterm>

  <para>
   The view <structname>pg_settings</structname> provides access to
   run-time parameters of the server.  It is essentially an alternative
   interface to the <command>SHOW</> and <command>SET</> commands.
   It also provides access to some facts about each parameter that are
   not directly available from <command>SHOW</>, such as minimum and
   maximum values.
  </para>

  <table>
   <title><structname>pg_settings</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>name</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>run-time configuration parameter name</entry>
     </row>
     <row>
      <entry><structfield>setting</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>current value of the parameter</entry>
     </row>
5494 5495 5496 5497 5498 5499
     <row>
      <entry><structfield>unit</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>implicit unit of the parameter</entry>
     </row>
5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517
     <row>
      <entry><structfield>category</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>logical group of the parameter</entry>
     </row>
     <row>
      <entry><structfield>short_desc</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>a brief description of the parameter</entry>
     </row>
     <row>
      <entry><structfield>extra_desc</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>additional, more detailed, information about the parameter</entry>
     </row>
5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571
     <row>
      <entry><structfield>context</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>context required to set the parameter's value</entry>
     </row>
     <row>
      <entry><structfield>vartype</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>parameter type (<literal>bool</>, <literal>integer</>,
       <literal>real</>, or <literal>string</>)
      </entry>
     </row>
     <row>
      <entry><structfield>source</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>source of the current parameter value</entry>
     </row>
     <row>
      <entry><structfield>min_val</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>minimum allowed value of the parameter (NULL for nonnumeric
      values)</entry>
     </row>
     <row>
      <entry><structfield>max_val</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>maximum allowed value of the parameter (NULL for nonnumeric
      values)</entry>
     </row>
    </tbody>
   </tgroup>
  </table>
  
  <para>
   The <structname>pg_settings</structname> view cannot be inserted into or
   deleted from, but it can be updated.  An <command>UPDATE</command> applied
   to a row of <structname>pg_settings</structname> is equivalent to executing
   the <xref linkend="SQL-SET" endterm="SQL-SET-title"> command on that named
   parameter. The change only affects the value used by the current
   session. If an <command>UPDATE</command> is issued within a transaction
   that is later aborted, the effects of the <command>UPDATE</command> command
   disappear when the transaction is rolled back. Once the surrounding
   transaction is committed, the effects will persist until the end of the
   session, unless overridden by another <command>UPDATE</command> or
   <command>SET</command>.
  </para>

 </sect1>

5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672
 <sect1 id="view-pg-shadow">
  <title><structname>pg_shadow</structname></title>

  <indexterm zone="view-pg-shadow">
   <primary>pg_shadow</primary>
  </indexterm>

  <para>
   The view <structname>pg_shadow</structname> exists for backwards
   compatibility: it emulates a catalog that existed in
   <productname>PostgreSQL</productname> before version 8.1.
   It shows properties of all roles that are marked as
   <structfield>rolcanlogin</>.
  </para>

  <para>
   The name stems from the fact that this table
   should not be readable by the public since it contains passwords.
   <link linkend="view-pg-user"><structname>pg_user</structname></link>
   is a publicly readable view on
   <structname>pg_shadow</structname> that blanks out the password field.
  </para>

  <table>
   <title><structname>pg_shadow</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry><structfield>usename</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
      <entry>User name</entry>
     </row>

     <row>
      <entry><structfield>usesysid</structfield></entry>
      <entry><type>oid</type></entry>
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
      <entry>ID of this user</entry>
     </row>

     <row>
      <entry><structfield>usecreatedb</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>User may create databases</entry>
     </row>

     <row>
      <entry><structfield>usesuper</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>User is a superuser</entry>
     </row>

     <row>
      <entry><structfield>usecatupd</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       User may update system catalogs.  (Even a superuser may not do
       this unless this column is true.)
      </entry>
     </row>

     <row>
      <entry><structfield>passwd</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Password (possibly encrypted)</entry>
     </row>

     <row>
      <entry><structfield>valuntil</structfield></entry>
      <entry><type>abstime</type></entry>
      <entry></entry>
      <entry>Password expiry time (only used for password authentication)</entry>
     </row>

     <row>
      <entry><structfield>useconfig</structfield></entry>
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>Session defaults for run-time configuration variables</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692
 <sect1 id="view-pg-stats">
  <title><structname>pg_stats</structname></title>

  <indexterm zone="view-pg-stats">
   <primary>pg_stats</primary>
  </indexterm>

  <para>
   The view <structname>pg_stats</structname> provides access to
   the information stored in the <link
   linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link>
   catalog.  This view allows access only to rows of
   <structname>pg_statistic</structname> that correspond to tables the
   user has permission to read, and therefore it is safe to allow public
   read access to this view.
  </para>

  <para>
   <structname>pg_stats</structname> is also designed to present the
   information in a more readable format than the underlying catalog
5693
   &mdash; at the cost that its schema must be extended whenever new slot types
5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813
   are defined for <structname>pg_statistic</structname>.
  </para>

  <table>
   <title><structname>pg_stats</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>schemaname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
      <entry>name of schema containing table</entry>
     </row>

     <row>
      <entry><structfield>tablename</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
      <entry>name of table</entry>
     </row>

     <row>
      <entry><structfield>attname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attname</literal></entry>
      <entry>name of the column described by this row</entry>
     </row>

     <row>
      <entry><structfield>null_frac</structfield></entry>
      <entry><type>real</type></entry>
      <entry></entry>
      <entry>fraction of column entries that are null</entry>
     </row>

     <row>
      <entry><structfield>avg_width</structfield></entry>
      <entry><type>integer</type></entry>
      <entry></entry>
      <entry>average width in bytes of column's entries</entry>
     </row>

     <row>
      <entry><structfield>n_distinct</structfield></entry>
      <entry><type>real</type></entry>
      <entry></entry>
      <entry>If greater than zero, the estimated number of distinct values
      in the column.  If less than zero, the negative of the number of
      distinct values divided by the number of rows.  (The negated form
      is used when <command>ANALYZE</> believes that the number of distinct
      values
      is likely to increase as the table grows; the positive form is used
      when the column seems to have a fixed number of possible values.)
      For example, -1 indicates a unique column in which the number of
      distinct values is the same as the number of rows.
      </entry>
     </row>

     <row>
      <entry><structfield>most_common_vals</structfield></entry>
      <entry><type>anyarray</type></entry>
      <entry></entry>
      <entry>A list of the most common values in the column. (NULL if
      no values seem to be more common than any others.)</entry>
     </row>

     <row>
      <entry><structfield>most_common_freqs</structfield></entry>
      <entry><type>real[]</type></entry>
      <entry></entry>
      <entry>A list of the frequencies of the most common values,
      i.e., number of occurrences of each divided by total number of rows.
      (NULL when <structfield>most_common_vals</structfield> is.)
     </entry>
     </row>

     <row>
      <entry><structfield>histogram_bounds</structfield></entry>
      <entry><type>anyarray</type></entry>
      <entry></entry>
      <entry>A list of values that divide the column's values into
      groups of approximately equal population.  The values in
      <structfield>most_common_vals</>, if present, are omitted from this
      histogram calculation.  (This column is NULL if the column data type
      does not have a <literal>&lt;</> operator or if the
      <structfield>most_common_vals</> list accounts for the entire
      population.)
      </entry>
     </row>

     <row>
      <entry><structfield>correlation</structfield></entry>
      <entry><type>real</type></entry>
      <entry></entry>
      <entry>Statistical correlation between physical row ordering and
      logical ordering of the column values.  This ranges from -1 to +1.
      When the value is near -1 or +1, an index scan on the column will
      be estimated to be cheaper than when it is near zero, due to reduction
      of random access to the disk.  (This column is NULL if the column data
      type does not have a <literal>&lt;</> operator.)
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   The maximum number of entries in the <structfield>most_common_vals</>
   and <structfield>histogram_bounds</> arrays can be set on a
   column-by-column basis using the <command>ALTER TABLE SET STATISTICS</>
   command, or globally by setting the
5814
   <xref linkend="guc-default-statistics-target"> run-time parameter.
5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858
  </para>

 </sect1>

 <sect1 id="view-pg-tables">
  <title><structname>pg_tables</structname></title>

  <indexterm zone="view-pg-tables">
   <primary>pg_tables</primary>
  </indexterm>

  <para>
   The view <structname>pg_tables</structname> provides access to
   useful information about each table in the database.
  </para>

  <table>
   <title><structname>pg_tables</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>schemaname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
      <entry>name of schema containing table</entry>
     </row>
     <row>
      <entry><structfield>tablename</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
      <entry>name of table</entry>
     </row>
     <row>
      <entry><structfield>tableowner</structfield></entry>
      <entry><type>name</type></entry>
5859
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
5860 5861
      <entry>name of table's owner</entry>
     </row>
5862 5863 5864 5865 5866 5867
     <row>
      <entry><structfield>tablespace</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.spcname</literal></entry>
      <entry>name of tablespace containing table (NULL if default for database)</entry>
     </row>
5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891
     <row>
      <entry><structfield>hasindexes</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhasindex</literal></entry>
      <entry>true if table has (or recently had) any indexes</entry>
     </row>
     <row>
      <entry><structfield>hasrules</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relhasrules</literal></entry>
      <entry>true if table has rules</entry>
     </row>
     <row>
      <entry><structfield>hastriggers</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.reltriggers</literal></entry>
      <entry>true if table has triggers</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

5892 5893
 <sect1 id="view-pg-timezone-abbrevs">
  <title><structname>pg_timezone_abbrevs</structname></title>
5894

5895 5896
  <indexterm zone="view-pg-timezone-abbrevs">
   <primary>pg_timezone_abbrevs</primary>
5897 5898 5899
  </indexterm>

  <para>
5900
   The view <structname>pg_timezone_abbrevs</structname> provides a list
5901 5902 5903 5904 5905 5906
   of time zone abbreviations that are currently recognized by the datetime
   input routines.  The contents of this view change when the
   <xref linkend="guc-timezone-abbreviations"> run-time parameter is modified.
  </para>

  <table>
5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959
   <title><structname>pg_timezone_abbrevs</> Columns</title>

   <tgroup cols=3>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>abbrev</structfield></entry>
      <entry><type>text</type></entry>
      <entry>time zone abbreviation</entry>
     </row>
     <row>
      <entry><structfield>utc_offset</structfield></entry>
      <entry><type>interval</type></entry>
      <entry>offset from UTC (positive means east of Greenwich)</entry>
     </row>
     <row>
      <entry><structfield>is_dst</structfield></entry>
      <entry><type>boolean</type></entry>
      <entry>true if this is a daylight-savings abbreviation</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

 <sect1 id="view-pg-timezone-names">
  <title><structname>pg_timezone_names</structname></title>

  <indexterm zone="view-pg-timezone-names">
   <primary>pg_timezone_names</primary>
  </indexterm>

  <para>
   The view <structname>pg_timezone_names</structname> provides a list
   of time zone names that are recognized by <command>SET TIMEZONE</>,
   along with their associated abbreviations, UTC offsets,
   and daylight-savings status.
   Unlike the abbreviations shown in <link
   linkend="view-pg-timezone-abbrevs"><structname>pg_timezone_abbrevs</structname></link>, many of these names imply a set of daylight-savings transition
   date rules.  Therefore, the associated information changes across local DST
   boundaries.  The displayed information is computed based on the current
   value of <function>CURRENT_TIMESTAMP</>.
  </para>

  <table>
   <title><structname>pg_timezone_names</> Columns</title>
5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972

   <tgroup cols=3>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>name</structfield></entry>
      <entry><type>text</type></entry>
5973 5974 5975 5976 5977
      <entry>time zone name</entry>
     </row>
     <row>
      <entry><structfield>abbrev</structfield></entry>
      <entry><type>text</type></entry>
5978 5979 5980 5981 5982 5983 5984 5985 5986 5987
      <entry>time zone abbreviation</entry>
     </row>
     <row>
      <entry><structfield>utc_offset</structfield></entry>
      <entry><type>interval</type></entry>
      <entry>offset from UTC (positive means east of Greenwich)</entry>
     </row>
     <row>
      <entry><structfield>is_dst</structfield></entry>
      <entry><type>boolean</type></entry>
5988
      <entry>true if currently observing daylight savings</entry>
5989 5990 5991 5992 5993 5994 5995
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006
 <sect1 id="view-pg-user">
  <title><structname>pg_user</structname></title>

  <indexterm zone="view-pg-user">
   <primary>pg_user</primary>
  </indexterm>

  <para>
   The view <structname>pg_user</structname> provides access to
   information about database users.  This is simply a publicly
   readable view of 
6007
   <link linkend="view-pg-shadow"><structname>pg_shadow</structname></link>
6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034
   that blanks out the password field.
  </para>

  <table>
   <title><structname>pg_user</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>usename</structfield></entry>
      <entry><type>name</type></entry>
      <entry></entry>
      <entry>User name</entry>
     </row>

     <row>
      <entry><structfield>usesysid</structfield></entry>
      <entry><type>int4</type></entry>
      <entry></entry>
6035
      <entry>User ID (arbitrary number used to reference this user)</entry>
6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072
     </row>

     <row>
      <entry><structfield>usecreatedb</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>User may create databases</entry>
     </row>

     <row>
      <entry><structfield>usesuper</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>User is a superuser</entry>
     </row>

     <row>
      <entry><structfield>usecatupd</structfield></entry>
      <entry><type>bool</type></entry>
      <entry></entry>
      <entry>
       User may update system catalogs.  (Even a superuser may not do
       this unless this column is true.)
      </entry>
     </row>

     <row>
      <entry><structfield>passwd</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
      <entry>Not the password (always reads as <literal>********</>)</entry>
     </row>

     <row>
      <entry><structfield>valuntil</structfield></entry>
      <entry><type>abstime</type></entry>
      <entry></entry>
6073
      <entry>Password expiry time (only used for password authentication)</entry>
6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127
     </row>

     <row>
      <entry><structfield>useconfig</structfield></entry>
      <entry><type>text[]</type></entry>
      <entry></entry>
      <entry>Session defaults for run-time configuration variables</entry>
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

 <sect1 id="view-pg-views">
  <title><structname>pg_views</structname></title>

  <indexterm zone="view-pg-views">
   <primary>pg_views</primary>
  </indexterm>

  <para>
   The view <structname>pg_views</structname> provides access to
   useful information about each view in the database.
  </para>

  <table>
   <title><structname>pg_views</> Columns</title>

   <tgroup cols=4>
    <thead>
     <row>
      <entry>Name</entry>
      <entry>Type</entry>
      <entry>References</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><structfield>schemaname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
      <entry>name of schema containing view</entry>
     </row>
     <row>
      <entry><structfield>viewname</structfield></entry>
      <entry><type>name</type></entry>
      <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
      <entry>name of view</entry>
     </row>
     <row>
      <entry><structfield>viewowner</structfield></entry>
      <entry><type>name</type></entry>
6128
      <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.rolname</literal></entry>
6129 6130 6131 6132 6133 6134
      <entry>name of view's owner</entry>
     </row>
     <row>
      <entry><structfield>definition</structfield></entry>
      <entry><type>text</type></entry>
      <entry></entry>
6135
      <entry>view definition (a reconstructed <command>SELECT</command> query)</entry>
6136 6137 6138 6139 6140 6141 6142
     </row>
    </tbody>
   </tgroup>
  </table>

 </sect1>

6143
</chapter>