gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

60 lines
7.5KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 69. System Catalog Declarations and Initial Contents</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="storage-page-layout.html" title="68.6. Database Page Layout" /><link rel="next" href="system-catalog-declarations.html" title="69.1. System Catalog Declaration Rules" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Chapter 69. System Catalog Declarations and Initial Contents</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="storage-page-layout.html" title="68.6. Database Page Layout">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="internals.html" title="Part VII. Internals">Up</a></td><th width="60%" align="center">Part VII. Internals</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="system-catalog-declarations.html" title="69.1. System Catalog Declaration Rules">Next</a></td></tr></table><hr></hr></div><div class="chapter" id="BKI"><div class="titlepage"><div><div><h2 class="title">Chapter 69. System Catalog Declarations and Initial Contents</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="system-catalog-declarations.html">69.1. System Catalog Declaration Rules</a></span></dt><dt><span class="sect1"><a href="system-catalog-initial-data.html">69.2. System Catalog Initial Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="system-catalog-initial-data.html#SYSTEM-CATALOG-INITIAL-DATA-FORMAT">69.2.1. Data File Format</a></span></dt><dt><span class="sect2"><a href="system-catalog-initial-data.html#SYSTEM-CATALOG-OID-ASSIGNMENT">69.2.2. OID Assignment</a></span></dt><dt><span class="sect2"><a href="system-catalog-initial-data.html#SYSTEM-CATALOG-OID-REFERENCES">69.2.3. OID Reference Lookup</a></span></dt><dt><span class="sect2"><a href="system-catalog-initial-data.html#SYSTEM-CATALOG-AUTO-ARRAY-TYPES">69.2.4. Automatic Creation of Array Types</a></span></dt><dt><span class="sect2"><a href="system-catalog-initial-data.html#SYSTEM-CATALOG-RECIPES">69.2.5. Recipes for Editing Data Files</a></span></dt></dl></dd><dt><span class="sect1"><a href="bki-format.html">69.3. <acronym class="acronym">BKI</acronym> File Format</a></span></dt><dt><span class="sect1"><a href="bki-commands.html">69.4. <acronym class="acronym">BKI</acronym> Commands</a></span></dt><dt><span class="sect1"><a href="bki-structure.html">69.5. Structure of the Bootstrap <acronym class="acronym">BKI</acronym> File</a></span></dt><dt><span class="sect1"><a href="bki-example.html">69.6. BKI Example</a></span></dt></dl></div><p>
  3. <span class="productname">PostgreSQL</span> uses many different system catalogs
  4. to keep track of the existence and properties of database objects, such as
  5. tables and functions. Physically there is no difference between a system
  6. catalog and a plain user table, but the backend C code knows the structure
  7. and properties of each catalog, and can manipulate it directly at a low
  8. level. Thus, for example, it is inadvisable to attempt to alter the
  9. structure of a catalog on-the-fly; that would break assumptions built into
  10. the C code about how rows of the catalog are laid out. But the structure
  11. of the catalogs can change between major versions.
  12. </p><p>
  13. The structures of the catalogs are declared in specially formatted C
  14. header files in the <code class="filename">src/include/catalog/</code> directory of
  15. the source tree. In particular, for each catalog there is a header file
  16. named after the catalog (e.g., <code class="filename">pg_class.h</code>
  17. for <code class="structname">pg_class</code>), which defines the set of columns
  18. the catalog has, as well as some other basic properties such as its OID.
  19. Other critical files defining the catalog structure
  20. include <code class="filename">indexing.h</code>, which defines the indexes present
  21. on all the system catalogs, and <code class="filename">toasting.h</code>, which
  22. defines TOAST tables for catalogs that need one.
  23. </p><p>
  24. Many of the catalogs have initial data that must be loaded into them
  25. during the <span class="quote">“<span class="quote">bootstrap</span>”</span> phase
  26. of <span class="application">initdb</span>, to bring the system up to a point
  27. where it is capable of executing SQL commands. (For
  28. example, <code class="filename">pg_class.h</code> must contain an entry for itself,
  29. as well as one for each other system catalog and index.) This
  30. initial data is kept in editable form in data files that are also stored
  31. in the <code class="filename">src/include/catalog/</code> directory. For example,
  32. <code class="filename">pg_proc.dat</code> describes all the initial rows that must
  33. be inserted into the <code class="structname">pg_proc</code> catalog.
  34. </p><p>
  35. To create the catalog files and load this initial data into them, a
  36. backend running in bootstrap mode reads a <acronym class="acronym">BKI</acronym>
  37. (Backend Interface) file containing commands and initial data.
  38. The <code class="filename">postgres.bki</code> file used in this mode is prepared
  39. from the aforementioned header and data files, while building
  40. a <span class="productname">PostgreSQL</span> distribution, by a Perl script
  41. named <code class="filename">genbki.pl</code>.
  42. Although it's specific to a particular <span class="productname">PostgreSQL</span>
  43. release, <code class="filename">postgres.bki</code> is platform-independent and is
  44. installed in the <code class="filename">share</code> subdirectory of the
  45. installation tree.
  46. </p><p>
  47. <code class="filename">genbki.pl</code> also produces a derived header file for
  48. each catalog, for example <code class="filename">pg_class_d.h</code> for
  49. the <code class="structname">pg_class</code> catalog. This file contains
  50. automatically-generated macro definitions, and may contain other macros,
  51. enum declarations, and so on that can be useful for client C code that
  52. reads a particular catalog.
  53. </p><p>
  54. Most PostgreSQL developers don't need to be directly concerned with
  55. the <acronym class="acronym">BKI</acronym> file, but almost any nontrivial feature
  56. addition in the backend will require modifying the catalog header files
  57. and/or initial data files. The rest of this chapter gives some
  58. information about that, and for completeness describes
  59. the <acronym class="acronym">BKI</acronym> file format.
  60. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="storage-page-layout.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="internals.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="system-catalog-declarations.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">68.6. Database Page Layout </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 69.1. System Catalog Declaration Rules</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1