Part 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 Postgres Pro has been understood. Later chapters in this part describe the server-side programming languages available in the Postgres Pro distribution as well as general issues concerning server-side programming languages. It is essential to read at least the earlier sections of Chapter 41 (covering functions) before diving into the material about server-side programming languages.

Table of Contents

41. Extending SQL
41.1. How Extensibility Works
41.2. The Postgres Pro Type System
41.3. User-Defined Functions
41.4. User-Defined Procedures
41.5. Query Language (SQL) Functions
41.6. Function Overloading
41.7. Function Volatility Categories
41.8. Procedural Language Functions
41.9. Internal Functions
41.10. C-Language Functions
41.11. Function Optimization Information
41.12. User-Defined Aggregates
41.13. User-Defined Types
41.14. User-Defined Operators
41.15. Operator Optimization Information
41.16. Interfacing Extensions to Indexes
41.17. Packaging Related Objects into an Extension
41.18. Extension Building Infrastructure
42. Triggers
42.1. Overview of Trigger Behavior
42.2. Visibility of Data Changes
42.3. Writing Trigger Functions in C
42.4. A Complete Trigger Example
43. Event Triggers
43.1. Overview of Event Trigger Behavior
43.2. Event Trigger Firing Matrix
43.3. Writing Event Trigger Functions in C
43.4. A Complete Event Trigger Example
43.5. A Table Rewrite Event Trigger Example
43.6. A Database Login Event Trigger Example
44. The Rule System
44.1. The Query Tree
44.2. Views and the Rule System
44.3. Materialized Views
44.4. Rules on INSERT, UPDATE, and DELETE
44.5. Rules and Privileges
44.6. Rules and Command Status
44.7. Rules Versus Triggers
45. Procedural Languages
45.1. Installing Procedural Languages
46. PL/pgSQLSQL Procedural Language
46.1. Overview
46.2. Structure of PL/pgSQL
46.3. Declarations
46.4. Expressions
46.5. Basic Statements
46.6. Control Structures
46.7. Cursors
46.8. Transaction Management
46.9. Errors and Messages
46.10. Trigger Functions
46.11. Packages
46.12. PL/pgSQL under the Hood
46.13. Tips for Developing in PL/pgSQL
46.14. Porting from Oracle PL/SQL
47. PL/Tcl — Tcl Procedural Language
47.1. Overview
47.2. PL/Tcl Functions and Arguments
47.3. Data Values in PL/Tcl
47.4. Global Data in PL/Tcl
47.5. Database Access from PL/Tcl
47.6. Trigger Functions in PL/Tcl
47.7. Event Trigger Functions in PL/Tcl
47.8. Error Handling in PL/Tcl
47.9. Explicit Subtransactions in PL/Tcl
47.10. Transaction Management
47.11. PL/Tcl Configuration
47.12. Tcl Procedure Names
48. PL/Perl — Perl Procedural Language
48.1. PL/Perl Functions and Arguments
48.2. Data Values in PL/Perl
48.3. Built-in Functions
48.4. Global Values in PL/Perl
48.5. Trusted and Untrusted PL/Perl
48.6. PL/Perl Triggers
48.7. PL/Perl Event Triggers
48.8. PL/Perl Under the Hood
49. PL/Python — Python Procedural Language
49.1. PL/Python Functions
49.2. Data Values
49.3. Sharing Data
49.4. Anonymous Code Blocks
49.5. Trigger Functions
49.6. Database Access
49.7. Explicit Subtransactions
49.8. Transaction Management
49.9. Utility Functions
49.10. Python 2 vs. Python 3
49.11. Environment Variables
50. Server Programming Interface
50.1. Interface Functions
50.2. Interface Support Functions
50.3. Memory Management
50.4. Transaction Management
50.5. Visibility of Data Changes
50.6. Examples
51. Background Worker Processes
52. Logical Decoding
52.1. Logical Decoding Examples
52.2. Logical Decoding Concepts
52.3. Streaming Replication Protocol Interface
52.4. Logical Decoding SQL Interface
52.5. System Catalogs Related to Logical Decoding
52.6. Logical Decoding Output Plugins
52.7. Logical Decoding Output Writers
52.8. Synchronous Replication Support for Logical Decoding
52.9. Streaming of Large Transactions for Logical Decoding
52.10. Two-phase Commit Support for Logical Decoding
53. Replication Progress Tracking
54. Archive Modules
54.1. Initialization Functions
54.2. Archive Module Callbacks