From 473b93287040b20017cc25a157cffdc5b978c254 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 23 Mar 2016 23:01:35 -0300 Subject: Support CREATE ACCESS METHOD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables external code to create access methods. This is useful so that extensions can add their own access methods which can be formally tracked for dependencies, so that DROP operates correctly. Also, having explicit support makes pg_dump work correctly. Currently only index AMs are supported, but we expect different types to be added in the future. Authors: Alexander Korotkov, Petr Jelínek Reviewed-By: Teodor Sigaev, Petr Jelínek, Jim Nasby Commitfest-URL: https://commitfest.postgresql.org/9/353/ Discussion: https://www.postgresql.org/message-id/CAPpHfdsXwZmojm6Dx+TJnpYk27kT4o7Ri6X_4OSWcByu1Rm+VA@mail.gmail.com --- doc/src/sgml/indexam.sgml | 6 ++ doc/src/sgml/ref/allfiles.sgml | 2 + doc/src/sgml/ref/create_access_method.sgml | 120 +++++++++++++++++++++++++++++ doc/src/sgml/ref/drop_access_method.sgml | 112 +++++++++++++++++++++++++++ doc/src/sgml/reference.sgml | 2 + 5 files changed, 242 insertions(+) create mode 100644 doc/src/sgml/ref/create_access_method.sgml create mode 100644 doc/src/sgml/ref/drop_access_method.sgml (limited to 'doc/src') diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 5f7befb8588..b36889b856b 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -57,6 +57,12 @@ to insert an appropriate row for themselves. + + Index access access methods can be defined and dropped using + and + SQL commands respectively. + + An index access method handler function must be declared to accept a single argument of type internal and to return the diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml index bf95453b6c6..77667bdebd1 100644 --- a/doc/src/sgml/ref/allfiles.sgml +++ b/doc/src/sgml/ref/allfiles.sgml @@ -52,6 +52,7 @@ Complete list of usable sgml source files in this directory. + @@ -94,6 +95,7 @@ Complete list of usable sgml source files in this directory. + diff --git a/doc/src/sgml/ref/create_access_method.sgml b/doc/src/sgml/ref/create_access_method.sgml new file mode 100644 index 00000000000..3c091f80210 --- /dev/null +++ b/doc/src/sgml/ref/create_access_method.sgml @@ -0,0 +1,120 @@ + + + + + CREATE ACCESS METHOD + + + + CREATE ACCESS METHOD + 7 + SQL - Language Statements + + + + CREATE ACCESS METHOD + define a new access method + + + + +CREATE ACCESS METHOD name + TYPE access_method_type + HANDLER handler_function + + + + + Description + + + CREATE ACCESS METHOD creates a new access method. + + + + The access method name must be unique within the database. + + + + Only superusers can define new access methods. + + + + + Parameters + + + + name + + + The name of the access method to be created. + + + + + + access_method_type + + + This clause specifies type of access method to define. + Only INDEX is supported at present. + + + + + + HANDLER handler_function + + handler_function is the + name of a previously registered function that will be called to + retrieve the struct which contains required parameters and functions + of access method to the core. The handler function must take single + argument of type internal, and its return type depends on the + type of access method; for INDEX access methods, it + must be index_am_handler. + + + + See for index access methods API. + + + + + + + + Examples + + + Create an access method heptree with + handler function heptree_handler: + +CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler; + + + + + + Compatibility + + + CREATE ACCESS METHOD is a + PostgreSQL extension. + + + + + See Also + + + + + + + + + diff --git a/doc/src/sgml/ref/drop_access_method.sgml b/doc/src/sgml/ref/drop_access_method.sgml new file mode 100644 index 00000000000..97ed77ebda7 --- /dev/null +++ b/doc/src/sgml/ref/drop_access_method.sgml @@ -0,0 +1,112 @@ + + + + + DROP ACCESS METHOD + + + + DROP ACCESS METHOD + 7 + SQL - Language Statements + + + + DROP ACCESS METHOD + remove an access method + + + + +DROP ACCESS METHOD [ IF EXISTS ] name [ CASCADE | RESTRICT ] + + + + + Description + + + DROP ACCESS METHOD removes an existing access method. + Only superusers can drop access methods. + + + + + + + + Parameters + + + + IF EXISTS + + + Do not throw an error if the access method does not exist. + A notice is issued in this case. + + + + + + name + + + The name of an existing access method. + + + + + + CASCADE + + + Automatically drop objects that depend on the access method + (such as operator classes, operator families, indexes). + + + + + + RESTRICT + + + Refuse to drop the access method if any objects depend on it. + This is the default. + + + + + + + + Examples + + + Drop the access method heptree: + +DROP ACCESS METHOD heptree; + + + + + Compatibility + + + DROP ACCESS METHOD is a + PostgreSQL extension. + + + + + See Also + + + + + + + diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml index 03020dfec42..8acdff1393f 100644 --- a/doc/src/sgml/reference.sgml +++ b/doc/src/sgml/reference.sgml @@ -80,6 +80,7 @@ &commit; &commitPrepared; ©Table; + &createAccessMethod; &createAggregate; &createCast; &createCollation; @@ -122,6 +123,7 @@ &delete; &discard; &do; + &dropAccessMethod; &dropAggregate; &dropCast; &dropCollation; -- cgit v1.2.3