V. Server Programming

Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.

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 34 (covering functions) before diving into the material about server-side programming languages.

Note: XCONLY: The following description applies only to Postgres-XC.

In Postgres-XC, you should be careful where server means. This could be a coordinator where your statement is handled first, or could be a datnode where your statement is actually handled. Current version of Postgres-XC keeps this as transparent as possible but it is a good thing to keep this in mind.

Table of Contents
34. Extending SQL
34.1. How Extensibility Works
34.2. The PostgreSQL Type System
34.3. User-defined Functions
34.4. Query Language (SQL) Functions
34.5. Function Overloading
34.6. Function Volatility Categories
34.7. Procedural Language Functions
34.8. Internal Functions
34.9. C-Language Functions
34.10. User-defined Aggregates
34.11. User-defined Types
34.12. User-defined Operators
34.13. Operator Optimization Information
34.14. Interfacing Extensions To Indexes
34.15. Packaging Related Objects into an Extension
34.16. Extension Building Infrastructure
35. Triggers
35.1. Overview of Trigger Behavior
35.2. Visibility of Data Changes
35.3. Writing Trigger Functions in C
35.4. A Complete Trigger Example
36. Event Triggers
36.1. Overview of Event Trigger Behavior
36.2. Event Trigger Firing Matrix
36.3. Writing Event Trigger Functions in C
36.4. A Complete Event Trigger Example
37. The Rule System
37.1. The Query Tree
37.2. Views and the Rule System
37.3. Materialized Views
37.4. Rules on INSERT, UPDATE, and DELETE
37.5. Rules and Privileges
37.6. Rules and Command Status
37.7. Rules Versus Triggers
38. Procedural Languages
38.1. Installing Procedural Languages
39. PL/pgSQL - SQL Procedural Language
39.1. Overview
39.2. Structure of PL/pgSQL
39.3. Declarations
39.4. Expressions
39.5. Basic Statements
39.6. Control Structures
39.7. Cursors
39.8. Errors and Messages
39.9. Trigger Procedures
39.10. PL/pgSQL Under the Hood
39.11. Tips for Developing in PL/pgSQL
39.12. Porting from Oracle PL/SQL
40. PL/Tcl - Tcl Procedural Language
40.1. Overview
40.2. PL/Tcl Functions and Arguments
40.3. Data Values in PL/Tcl
40.4. Global Data in PL/Tcl
40.5. Database Access from PL/Tcl
40.6. Trigger Procedures in PL/Tcl
40.7. Modules and the unknown Command
40.8. Tcl Procedure Names
41. PL/Perl - Perl Procedural Language
41.1. PL/Perl Functions and Arguments
41.2. Data Values in PL/Perl
41.3. Built-in Functions
41.4. Global Values in PL/Perl
41.5. Trusted and Untrusted PL/Perl
41.6. PL/Perl Triggers
41.7. PL/Perl Under the Hood
42. PL/Python - Python Procedural Language
42.1. Python 2 vs. Python 3
42.2. PL/Python Functions
42.3. Data Values
42.4. Sharing Data
42.5. Anonymous Code Blocks
42.6. Trigger Functions
42.7. Database Access
42.8. Explicit Subtransactions
42.9. Utility Functions
42.10. Environment Variables
43. Server Programming Interface
43.1. Interface Functions
43.2. Interface Support Functions
43.3. Memory Management
43.4. Visibility of Data Changes
43.5. Examples
44. Background Worker Processes