| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/create_access_method.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="sql-create-access-method"> |
| 7 |
<indexterm zone="sql-create-access-method"> |
| 8 |
<primary>CREATE ACCESS METHOD</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle>CREATE ACCESS METHOD</refentrytitle> |
| 13 |
<manvolnum>7</manvolnum> |
| 14 |
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>CREATE ACCESS METHOD</refname> |
| 19 |
<refpurpose>define a new access method</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<synopsis> |
| 24 |
CREATE ACCESS METHOD <replaceable class="parameter">name</replaceable> |
| 25 |
TYPE <replaceable class="parameter">access_method_type</replaceable> |
| 26 |
HANDLER <replaceable class="parameter">handler_function</replaceable> |
| 27 |
</synopsis> |
| 28 |
</refsynopsisdiv> |
| 29 |
|
| 30 |
<refsect1> |
| 31 |
<title>Description</title> |
| 32 |
|
| 33 |
<para> |
| 34 |
<command>CREATE ACCESS METHOD</command> creates a new access method. |
| 35 |
</para> |
| 36 |
|
| 37 |
<para> |
| 38 |
The access method name must be unique within the database. |
| 39 |
</para> |
| 40 |
|
| 41 |
<para> |
| 42 |
Only superusers can define new access methods. |
| 43 |
</para> |
| 44 |
</refsect1> |
| 45 |
|
| 46 |
<refsect1> |
| 47 |
<title>Parameters</title> |
| 48 |
|
| 49 |
<variablelist> |
| 50 |
<varlistentry> |
| 51 |
<term><replaceable class="parameter">name</replaceable></term> |
| 52 |
<listitem> |
| 53 |
<para> |
| 54 |
The name of the access method to be created. |
| 55 |
</para> |
| 56 |
</listitem> |
| 57 |
</varlistentry> |
| 58 |
|
| 59 |
<varlistentry> |
| 60 |
<term><replaceable class="parameter">access_method_type</replaceable></term> |
| 61 |
<listitem> |
| 62 |
<para> |
| 63 |
This clause specifies the type of access method to define. |
| 64 |
Only <literal>TABLE</literal> and <literal>INDEX</literal> |
| 65 |
are supported at present. |
| 66 |
</para> |
| 67 |
</listitem> |
| 68 |
</varlistentry> |
| 69 |
|
| 70 |
<varlistentry> |
| 71 |
<term><replaceable class="parameter">handler_function</replaceable></term> |
| 72 |
<listitem> |
| 73 |
<para> |
| 74 |
<replaceable class="parameter">handler_function</replaceable> is the |
| 75 |
name (possibly schema-qualified) of a previously registered function |
| 76 |
that represents the access method. The handler function must be |
| 77 |
declared to take a single argument of type <type>internal</type>, |
| 78 |
and its return type depends on the type of access method; |
| 79 |
for <literal>TABLE</literal> access methods, it must |
| 80 |
be <type>table_am_handler</type> and for <literal>INDEX</literal> |
| 81 |
access methods, it must be <type>index_am_handler</type>. |
| 82 |
The C-level API that the handler function must implement varies |
| 83 |
depending on the type of access method. The table access method API |
| 84 |
is described in <xref linkend="tableam"/> and the index access method |
| 85 |
API is described in <xref linkend="indexam"/>. |
| 86 |
</para> |
| 87 |
</listitem> |
| 88 |
</varlistentry> |
| 89 |
</variablelist> |
| 90 |
</refsect1> |
| 91 |
|
| 92 |
<refsect1> |
| 93 |
<title>Examples</title> |
| 94 |
|
| 95 |
<para> |
| 96 |
Create an index access method <literal>heptree</literal> with |
| 97 |
handler function <literal>heptree_handler</literal>: |
| 98 |
<programlisting> |
| 99 |
CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler; |
| 100 |
</programlisting></para> |
| 101 |
</refsect1> |
| 102 |
|
| 103 |
<refsect1> |
| 104 |
<title>Compatibility</title> |
| 105 |
|
| 106 |
<para> |
| 107 |
<command>CREATE ACCESS METHOD</command> is a |
| 108 |
<productname>PostgreSQL</productname> extension. |
| 109 |
</para> |
| 110 |
</refsect1> |
| 111 |
|
| 112 |
<refsect1> |
| 113 |
<title>See Also</title> |
| 114 |
|
| 115 |
<simplelist type="inline"> |
| 116 |
<member><xref linkend="sql-drop-access-method"/></member> |
| 117 |
<member><xref linkend="sql-createopclass"/></member> |
| 118 |
<member><xref linkend="sql-createopfamily"/></member> |
| 119 |
</simplelist> |
| 120 |
</refsect1> |
| 121 |
|
| 122 |
</refentry> |