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

Table of Contents

40. Extending SQL
40.1. How Extensibility Works
40.2. The Postgres Pro Type System
40.3. User-Defined Functions
40.4. User-Defined Procedures
40.5. Query Language (SQL) Functions
40.6. Function Overloading
40.7. Function Volatility Categories
40.8. Procedural Language Functions
40.9. Internal Functions
40.10. C-Language Functions
40.11. Function Optimization Information
40.12. User-Defined Aggregates
40.13. User-Defined Types
40.14. User-Defined Operators
40.15. Operator Optimization Information
40.16. Interfacing Extensions to Indexes
40.17. Packaging Related Objects into an Extension
40.18. Extension Building Infrastructure
41. Triggers
41.1. Overview of Trigger Behavior
41.2. Visibility of Data Changes
41.3. Writing Trigger Functions in C
41.4. A Complete Trigger Example
42. Event Triggers
42.1. Overview of Event Trigger Behavior
42.2. Event Trigger Firing Matrix
42.3. Writing Event Trigger Functions in C
42.4. A C language Event Trigger Example
42.5. A Table Rewrite Event Trigger Example
42.6. A Database Login Event Trigger Example
43. The Rule System
43.1. The Query Tree
43.2. Views and the Rule System
43.3. Materialized Views
43.4. Rules on INSERT, UPDATE, and DELETE
43.5. Rules and Privileges
43.6. Rules and Command Status
43.7. Rules Versus Triggers
44. Procedural Languages
44.1. Installing Procedural Languages
45. PL/pgSQLSQL Procedural Language
45.1. Overview
45.2. Structure of PL/pgSQL
45.3. Declarations
45.4. Expressions
45.5. Basic Statements
45.6. Control Structures
45.7. Cursors
45.8. Transaction Management
45.9. Errors and Messages
45.10. Trigger Functions
45.11. Packages
45.12. PL/pgSQL under the Hood
45.13. Tips for Developing in PL/pgSQL
45.14. Porting from Oracle PL/SQL
46. PL/Tcl — Tcl Procedural Language
46.1. Overview
46.2. PL/Tcl Functions and Arguments
46.3. Data Values in PL/Tcl
46.4. Global Data in PL/Tcl
46.5. Database Access from PL/Tcl
46.6. Trigger Functions in PL/Tcl
46.7. Event Trigger Functions in PL/Tcl
46.8. Error Handling in PL/Tcl
46.9. Explicit Subtransactions in PL/Tcl
46.10. Transaction Management
46.11. PL/Tcl Configuration
46.12. Tcl Procedure Names
47. PL/Perl — Perl Procedural Language
47.1. PL/Perl Functions and Arguments
47.2. Data Values in PL/Perl
47.3. Built-in Functions
47.4. Global Values in PL/Perl
47.5. Trusted and Untrusted PL/Perl
47.6. PL/Perl Triggers
47.7. PL/Perl Event Triggers
47.8. PL/Perl Under the Hood
48. PL/Python — Python Procedural Language
48.1. PL/Python Functions
48.2. Data Values
48.3. Sharing Data
48.4. Anonymous Code Blocks
48.5. Trigger Functions
48.6. Database Access
48.7. Explicit Subtransactions
48.8. Transaction Management
48.9. Utility Functions
48.10. Python 2 vs. Python 3
48.11. Environment Variables
49. Server Programming Interface
49.1. Interface Functions
49.2. Interface Support Functions
49.3. Memory Management
49.4. Transaction Management
49.5. Visibility of Data Changes
49.6. Examples
50. Background Worker Processes
51. Logical Decoding
51.1. Logical Decoding Examples
51.2. Logical Decoding Concepts
51.3. Streaming Replication Protocol Interface
51.4. Logical Decoding SQL Interface
51.5. System Catalogs Related to Logical Decoding
51.6. Logical Decoding Output Plugins
51.7. Logical Decoding Output Writers
51.8. Synchronous Replication Support for Logical Decoding
51.9. Streaming of Large Transactions for Logical Decoding
51.10. Two-phase Commit Support for Logical Decoding
52. Replication Progress Tracking
53. Archive Modules
53.1. Initialization Functions
53.2. Archive Module Callbacks