Supported Versions: Current (16) / 15 / 14 / 13 / 12
Development Versions: devel
Unsupported versions: 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
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.

V. Server Programming

This part is about extending the server functionality with user-defined functions, data types, triggers, etc. These are advanced topics which should probably be approached only after all the other user documentation about PostgreSQL has been understood. Later chapters in this part describe the server-side programming languages available in the PostgreSQL distribution as well as general issues concerning server-side programming languages. It is essential to read at least the earlier sections of Chapter 32 (covering functions) before diving into the material about server-side programming languages.

Table of Contents
32. Extending SQL
32.1. How Extensibility Works
32.2. The PostgreSQL Type System
32.3. User-Defined Functions
32.4. Query Language (SQL) Functions
32.5. Function Overloading
32.6. Function Volatility Categories
32.7. Procedural Language Functions
32.8. Internal Functions
32.9. C-Language Functions
32.10. User-Defined Aggregates
32.11. User-Defined Types
32.12. User-Defined Operators
32.13. Operator Optimization Information
32.14. Interfacing Extensions To Indexes
33. Triggers
33.1. Overview of Trigger Behavior
33.2. Visibility of Data Changes
33.3. Writing Trigger Functions in C
33.4. A Complete Example
34. The Rule System
34.1. The Query Tree
34.2. Views and the Rule System
34.3. Rules on INSERT, UPDATE, and DELETE
34.4. Rules and Privileges
34.5. Rules and Command Status
34.6. Rules versus Triggers
35. Procedural Languages
35.1. Installing Procedural Languages
36. PL/pgSQL - SQL Procedural Language
36.1. Overview
36.2. Tips for Developing in PL/pgSQL
36.3. Structure of PL/pgSQL
36.4. Declarations
36.5. Expressions
36.6. Basic Statements
36.7. Control Structures
36.8. Cursors
36.9. Errors and Messages
36.10. Trigger Procedures
36.11. Porting from Oracle PL/SQL
37. PL/Tcl - Tcl Procedural Language
37.1. Overview
37.2. PL/Tcl Functions and Arguments
37.3. Data Values in PL/Tcl
37.4. Global Data in PL/Tcl
37.5. Database Access from PL/Tcl
37.6. Trigger Procedures in PL/Tcl
37.7. Modules and the unknown command
37.8. Tcl Procedure Names
38. PL/Perl - Perl Procedural Language
38.1. PL/Perl Functions and Arguments
38.2. Database Access from PL/Perl
38.3. Data Values in PL/Perl
38.4. Global Values in PL/Perl
38.5. Trusted and Untrusted PL/Perl
38.6. PL/Perl Triggers
38.7. Limitations and Missing Features
39. PL/Python - Python Procedural Language
39.1. PL/Python Functions
39.2. Trigger Functions
39.3. Database Access
40. Server Programming Interface
40.1. Interface Functions
40.2. Interface Support Functions
40.3. Memory Management
40.4. Visibility of Data Changes
40.5. Examples