1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter32.Extending SQL</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="server-programming.html" title="PartV.Server Programming">
<link rel="prev" href="server-programming.html" title="PartV.Server Programming">
<link rel="next" href="extend-type-system.html" title="32.2.The PostgreSQL Type System">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en" id="extend">
<div class="titlepage"><div><div><h2 class="title">
<a name="extend"></a>Chapter32.Extending <acronym class="acronym">SQL</acronym></h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="extend.html#extend-how">32.1. How Extensibility Works</a></span></dt>
<dt><span class="sect1"><a href="extend-type-system.html">32.2. The <span class="productname">PostgreSQL</span> Type System</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="extend-type-system.html#id703669">32.2.1. Base Types</a></span></dt>
<dt><span class="sect2"><a href="extend-type-system.html#id703701">32.2.2. Composite Types</a></span></dt>
<dt><span class="sect2"><a href="extend-type-system.html#id703741">32.2.3. Domains</a></span></dt>
<dt><span class="sect2"><a href="extend-type-system.html#id703774">32.2.4. Pseudo-Types</a></span></dt>
<dt><span class="sect2"><a href="extend-type-system.html#extend-types-polymorphic">32.2.5. Polymorphic Types</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="xfunc.html">32.3. User-Defined Functions</a></span></dt>
<dt><span class="sect1"><a href="xfunc-sql.html">32.4. Query Language (<acronym class="acronym">SQL</acronym>) Functions</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="xfunc-sql.html#xfunc-sql-base-functions">32.4.1. <acronym class="acronym">SQL</acronym> Functions on Base Types</a></span></dt>
<dt><span class="sect2"><a href="xfunc-sql.html#id704549">32.4.2. <acronym class="acronym">SQL</acronym> Functions on Composite Types</a></span></dt>
<dt><span class="sect2"><a href="xfunc-sql.html#xfunc-output-parameters">32.4.3. Functions with Output Parameters</a></span></dt>
<dt><span class="sect2"><a href="xfunc-sql.html#xfunc-sql-table-functions">32.4.4. <acronym class="acronym">SQL</acronym> Functions as Table Sources</a></span></dt>
<dt><span class="sect2"><a href="xfunc-sql.html#id705091">32.4.5. <acronym class="acronym">SQL</acronym> Functions Returning Sets</a></span></dt>
<dt><span class="sect2"><a href="xfunc-sql.html#id705221">32.4.6. Polymorphic <acronym class="acronym">SQL</acronym> Functions</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="xfunc-overload.html">32.5. Function Overloading</a></span></dt>
<dt><span class="sect1"><a href="xfunc-volatility.html">32.6. Function Volatility Categories</a></span></dt>
<dt><span class="sect1"><a href="xfunc-pl.html">32.7. Procedural Language Functions</a></span></dt>
<dt><span class="sect1"><a href="xfunc-internal.html">32.8. Internal Functions</a></span></dt>
<dt><span class="sect1"><a href="xfunc-c.html">32.9. C-Language Functions</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="xfunc-c.html#xfunc-c-dynload">32.9.1. Dynamic Loading</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#xfunc-c-basetype">32.9.2. Base Types in C-Language Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#id707272">32.9.3. Calling Conventions Version 0 for C-Language Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#id707493">32.9.4. Calling Conventions Version 1 for C-Language Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#id707920">32.9.5. Writing Code</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#dfunc">32.9.6. Compiling and Linking Dynamically-Loaded Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#xfunc-c-pgxs">32.9.7. Extension Building Infrastructure</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#id709371">32.9.8. Composite-Type Arguments in C-Language Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#id709538">32.9.9. Returning Rows (Composite Types) from C-Language Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#xfunc-c-return-set">32.9.10. Returning Sets from C-Language Functions</a></span></dt>
<dt><span class="sect2"><a href="xfunc-c.html#id710389">32.9.11. Polymorphic Arguments and Return Types</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="xaggr.html">32.10. User-Defined Aggregates</a></span></dt>
<dt><span class="sect1"><a href="xtypes.html">32.11. User-Defined Types</a></span></dt>
<dt><span class="sect1"><a href="xoper.html">32.12. User-Defined Operators</a></span></dt>
<dt><span class="sect1"><a href="xoper-optimization.html">32.13. Operator Optimization Information</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="xoper-optimization.html#id711539">32.13.1. <code class="literal">COMMUTATOR</code></a></span></dt>
<dt><span class="sect2"><a href="xoper-optimization.html#id711762">32.13.2. <code class="literal">NEGATOR</code></a></span></dt>
<dt><span class="sect2"><a href="xoper-optimization.html#id711854">32.13.3. <code class="literal">RESTRICT</code></a></span></dt>
<dt><span class="sect2"><a href="xoper-optimization.html#id712162">32.13.4. <code class="literal">JOIN</code></a></span></dt>
<dt><span class="sect2"><a href="xoper-optimization.html#id712320">32.13.5. <code class="literal">HASHES</code></a></span></dt>
<dt><span class="sect2"><a href="xoper-optimization.html#id712448">32.13.6. <code class="literal">MERGES</code> (<code class="literal">SORT1</code>, <code class="literal">SORT2</code>, <code class="literal">LTCMP</code>, <code class="literal">GTCMP</code>)</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="xindex.html">32.14. Interfacing Extensions To Indexes</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="xindex.html#xindex-im">32.14.1. Index Methods and Operator Classes</a></span></dt>
<dt><span class="sect2"><a href="xindex.html#xindex-strategies">32.14.2. Index Method Strategies</a></span></dt>
<dt><span class="sect2"><a href="xindex.html#xindex-support">32.14.3. Index Method Support Routines</a></span></dt>
<dt><span class="sect2"><a href="xindex.html#xindex-example">32.14.4. An Example</a></span></dt>
<dt><span class="sect2"><a href="xindex.html#xindex-opclass-crosstype">32.14.5. Cross-Data-Type Operator Classes</a></span></dt>
<dt><span class="sect2"><a href="xindex.html#xindex-opclass-dependencies">32.14.6. System Dependencies on Operator Classes</a></span></dt>
<dt><span class="sect2"><a href="xindex.html#xindex-opclass-features">32.14.7. Special Features of Operator Classes</a></span></dt>
</dl></dd>
</dl>
</div>
<a name="id703393"></a><p> In the sections that follow, we will discuss how you
can extend the <span class="productname">PostgreSQL</span>
<acronym class="acronym">SQL</acronym> query language by adding:
</p>
<div class="itemizedlist"><ul type="bullet" compact>
<li style="list-style-type: disc"><p> functions (starting in <a href="xfunc.html" title="32.3.User-Defined Functions">Section32.3, “User-Defined Functions”</a>)
</p></li>
<li style="list-style-type: disc"><p> aggregates (starting in <a href="xaggr.html" title="32.10.User-Defined Aggregates">Section32.10, “User-Defined Aggregates”</a>)
</p></li>
<li style="list-style-type: disc"><p> data types (starting in <a href="xtypes.html" title="32.11.User-Defined Types">Section32.11, “User-Defined Types”</a>)
</p></li>
<li style="list-style-type: disc"><p> operators (starting in <a href="xoper.html" title="32.12.User-Defined Operators">Section32.12, “User-Defined Operators”</a>)
</p></li>
<li style="list-style-type: disc"><p> operator classes for indexes (starting in <a href="xindex.html" title="32.14.Interfacing Extensions To Indexes">Section32.14, “Interfacing Extensions To Indexes”</a>)
</p></li>
</ul></div>
<p>
</p>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="extend-how"></a>32.1.How Extensibility Works</h2></div></div></div>
<p> <span class="productname">PostgreSQL</span> is extensible because its operation is
catalog-driven. If you are familiar with standard
relational database systems, you know that they store information
about databases, tables, columns, etc., in what are
commonly known as system catalogs. (Some systems call
this the data dictionary.) The catalogs appear to the
user as tables like any other, but the <acronym class="acronym">DBMS</acronym> stores
its internal bookkeeping in them. One key difference
between <span class="productname">PostgreSQL</span> and standard relational database systems is
that <span class="productname">PostgreSQL</span> stores much more information in its
catalogs: not only information about tables and columns,
but also information about data types, functions, access
methods, and so on. These tables can be modified by
the user, and since <span class="productname">PostgreSQL</span> bases its operation
on these tables, this means that <span class="productname">PostgreSQL</span> can be
extended by users. By comparison, conventional
database systems can only be extended by changing hardcoded
procedures in the source code or by loading modules
specially written by the <acronym class="acronym">DBMS</acronym> vendor.
</p>
<p> The <span class="productname">PostgreSQL</span> server can moreover
incorporate user-written code into itself through dynamic loading.
That is, the user can specify an object code file (e.g., a shared
library) that implements a new type or function, and
<span class="productname">PostgreSQL</span> will load it as required.
Code written in <acronym class="acronym">SQL</acronym> is even more trivial to add
to the server. This ability to modify its operation “<span class="quote">on the
fly</span>” makes <span class="productname">PostgreSQL</span> uniquely
suited for rapid prototyping of new applications and storage
structures.
</p>
</div>
</div></body>
</html>
|