2000-03-31 05:27:42 +02:00
|
|
|
<!--
|
2003-04-13 11:57:35 +02:00
|
|
|
$Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.22 2003/04/13 09:57:35 petere Exp $
|
2000-03-31 05:27:42 +02:00
|
|
|
-->
|
|
|
|
|
1999-07-22 17:11:05 +02:00
|
|
|
<chapter id="extend">
|
2003-04-10 03:22:45 +02:00
|
|
|
<title>Extending <acronym>SQL</acronym></title>
|
1999-07-22 17:11:05 +02:00
|
|
|
|
2002-11-03 02:31:32 +01:00
|
|
|
<indexterm zone="extend">
|
|
|
|
<primary>extending SQL</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
1999-07-22 17:11:05 +02:00
|
|
|
<para>
|
|
|
|
In the sections that follow, we will discuss how you
|
2001-11-21 06:53:41 +01:00
|
|
|
can extend the <productname>PostgreSQL</productname>
|
1999-07-22 17:11:05 +02:00
|
|
|
<acronym>SQL</acronym> query language by adding:
|
|
|
|
|
|
|
|
<itemizedlist spacing="compact" mark="bullet">
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-04-10 03:22:45 +02:00
|
|
|
functions (starting in <xref linkend="xfunc">)
|
1999-07-22 17:11:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-04-10 03:22:45 +02:00
|
|
|
data types (starting in <xref linkend="xtypes">)
|
1999-07-22 17:11:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-04-10 03:22:45 +02:00
|
|
|
operators (starting in <xref linkend="xoper">)
|
1999-07-22 17:11:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-04-10 03:22:45 +02:00
|
|
|
aggregates (starting in <xref linkend="xaggr">)
|
1999-07-22 17:11:05 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
|
2000-09-29 22:21:34 +02:00
|
|
|
<sect1 id="extend-how">
|
1999-07-22 17:11:05 +02:00
|
|
|
<title>How Extensibility Works</title>
|
|
|
|
|
|
|
|
<para>
|
2001-11-21 06:53:41 +01:00
|
|
|
<productname>PostgreSQL</productname> is extensible because its operation is
|
1999-07-22 17:11:05 +02:00
|
|
|
catalog-driven. If you are familiar with standard
|
2003-04-10 03:22:45 +02:00
|
|
|
relational database systems, you know that they store information
|
1999-07-22 17:11:05 +02:00
|
|
|
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
|
2001-01-14 00:58:55 +01:00
|
|
|
user as tables like any other, but the <acronym>DBMS</acronym> stores
|
1999-07-22 17:11:05 +02:00
|
|
|
its internal bookkeeping in them. One key difference
|
2003-04-10 03:22:45 +02:00
|
|
|
between <productname>PostgreSQL</productname> and standard relational database systems is
|
2001-11-21 06:53:41 +01:00
|
|
|
that <productname>PostgreSQL</productname> stores much more information in its
|
2003-04-10 03:22:45 +02:00
|
|
|
catalogs: not only information about tables and columns,
|
|
|
|
but also information about data types, functions, access
|
2001-01-14 00:58:55 +01:00
|
|
|
methods, and so on. These tables can be modified by
|
2003-04-10 03:22:45 +02:00
|
|
|
the user, and since <productname>PostgreSQL</productname> bases its operation
|
2001-11-21 06:53:41 +01:00
|
|
|
on these tables, this means that <productname>PostgreSQL</productname> can be
|
1999-07-22 17:11:05 +02:00
|
|
|
extended by users. By comparison, conventional
|
|
|
|
database systems can only be extended by changing hardcoded
|
2003-04-10 03:22:45 +02:00
|
|
|
procedures in the source code or by loading modules
|
2002-01-07 03:29:15 +01:00
|
|
|
specially written by the <acronym>DBMS</acronym> vendor.
|
1999-07-22 17:11:05 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2003-04-10 03:22:45 +02:00
|
|
|
The PostgreSQL server can moreover incorporate user-written code into
|
1999-07-22 17:11:05 +02:00
|
|
|
itself through dynamic loading. That is, the user can
|
2003-04-10 03:22:45 +02:00
|
|
|
specify an object code file (e.g., a shared library) that implements a new type or function,
|
2001-11-21 06:53:41 +01:00
|
|
|
and <productname>PostgreSQL</productname> will load it as required. Code written
|
2002-01-07 03:29:15 +01:00
|
|
|
in <acronym>SQL</acronym> is even more trivial to add to the server.
|
2001-09-13 17:55:24 +02:00
|
|
|
This ability to modify its operation <quote>on the fly</quote> makes
|
2001-11-21 06:53:41 +01:00
|
|
|
<productname>PostgreSQL</productname> uniquely suited for rapid prototyping of new
|
1999-07-22 17:11:05 +02:00
|
|
|
applications and storage structures.
|
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
2000-09-29 22:21:34 +02:00
|
|
|
<sect1 id="type-system">
|
2001-11-21 06:53:41 +01:00
|
|
|
<title>The <productname>PostgreSQL</productname> Type System</title>
|
1999-07-22 17:11:05 +02:00
|
|
|
|
2002-11-03 02:31:32 +01:00
|
|
|
<indexterm zone="type-system">
|
|
|
|
<primary>extending SQL</primary>
|
|
|
|
<secondary>types</secondary>
|
|
|
|
</indexterm>
|
|
|
|
|
|
|
|
<indexterm zone="type-system">
|
|
|
|
<primary>data types</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
1999-07-22 17:11:05 +02:00
|
|
|
<para>
|
2003-04-10 03:22:45 +02:00
|
|
|
Data types are divided into base types and composite types.
|
2002-01-07 03:29:15 +01:00
|
|
|
Base types are those, like <type>int4</type>, that are implemented
|
|
|
|
in a language such as C. They generally correspond to
|
2003-04-10 03:22:45 +02:00
|
|
|
what are often known as abstract data types. <productname>PostgreSQL</productname>
|
1999-07-22 17:11:05 +02:00
|
|
|
can only operate on such types through methods provided
|
|
|
|
by the user and only understands the behavior of such
|
|
|
|
types to the extent that the user describes them.
|
|
|
|
Composite types are created whenever the user creates a
|
2003-04-10 03:22:45 +02:00
|
|
|
table. The
|
2001-09-13 17:55:24 +02:00
|
|
|
user can <quote>look inside</quote> at the attributes of these types
|
2003-04-10 03:22:45 +02:00
|
|
|
from the query language.
|
1999-07-22 17:11:05 +02:00
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
2003-04-10 03:22:45 +02:00
|
|
|
&xfunc;
|
|
|
|
&xtypes;
|
|
|
|
&xoper;
|
|
|
|
&xaggr;
|
2003-04-13 11:57:35 +02:00
|
|
|
&xindex;
|
1999-07-22 17:11:05 +02:00
|
|
|
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
2000-03-31 05:27:42 +02:00
|
|
|
mode:sgml
|
1999-07-22 17:11:05 +02:00
|
|
|
sgml-omittag:nil
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"./reference.ced"
|
|
|
|
sgml-exposed-tags:nil
|
2000-03-31 05:27:42 +02:00
|
|
|
sgml-local-catalogs:("/usr/lib/sgml/catalog")
|
1999-07-22 17:11:05 +02:00
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|