Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

Chapter 36. Extending SQL

Table of Contents
36.1. How Extensibility Works
36.2. The PostgreSQL Type System
36.2.1. Base Types
36.2.2. Composite Types
36.2.3. Domains
36.2.4. Pseudo-Types
36.2.5. Polymorphic Types
36.3. User-defined Functions
36.4. Query Language (SQL) Functions
36.4.1. Arguments for SQL Functions
36.4.2. SQL Functions on Base Types
36.4.3. SQL Functions on Composite Types
36.4.4. SQL Functions with Output Parameters
36.4.5. SQL Functions with Variable Numbers of Arguments
36.4.6. SQL Functions with Default Values for Arguments
36.4.7. SQL Functions as Table Sources
36.4.8. SQL Functions Returning Sets
36.4.9. SQL Functions Returning TABLE
36.4.10. Polymorphic SQL Functions
36.4.11. SQL Functions with Collations
36.5. Function Overloading
36.6. Function Volatility Categories
36.7. Procedural Language Functions
36.8. Internal Functions
36.9. C-Language Functions
36.9.1. Dynamic Loading
36.9.2. Base Types in C-Language Functions
36.9.3. Version 0 Calling Conventions
36.9.4. Version 1 Calling Conventions
36.9.5. Writing Code
36.9.6. Compiling and Linking Dynamically-loaded Functions
36.9.7. Composite-type Arguments
36.9.8. Returning Rows (Composite Types)
36.9.9. Returning Sets
36.9.10. Polymorphic Arguments and Return Types
36.9.11. Transform Functions
36.9.12. Shared Memory and LWLocks
36.9.13. Using C++ for Extensibility
36.10. User-defined Aggregates
36.10.1. Moving-Aggregate Mode
36.10.2. Polymorphic and Variadic Aggregates
36.10.3. Ordered-Set Aggregates
36.10.4. Partial Aggregation
36.10.5. Support Functions for Aggregates
36.11. User-defined Types
36.12. User-defined Operators
36.13. Operator Optimization Information
36.13.1. COMMUTATOR
36.13.2. NEGATOR
36.13.3. RESTRICT
36.13.4. JOIN
36.13.5. HASHES
36.13.6. MERGES
36.14. Interfacing Extensions To Indexes
36.14.1. Index Methods and Operator Classes
36.14.2. Index Method Strategies
36.14.3. Index Method Support Routines
36.14.4. An Example
36.14.5. Operator Classes and Operator Families
36.14.6. System Dependencies on Operator Classes
36.14.7. Ordering Operators
36.14.8. Special Features of Operator Classes
36.15. Packaging Related Objects into an Extension
36.15.1. Extension Files
36.15.2. Extension Relocatability
36.15.3. Extension Configuration Tables
36.15.4. Extension Updates
36.15.5. Security Considerations for Extensions
36.15.6. Extension Example
36.16. Extension Building Infrastructure

In the sections that follow, we will discuss how you can extend the PostgreSQL SQL query language by adding: