更新时间:2021-07-23 20:37:08
coverpage
PostgreSQL Server Programming Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files eBooks discount offers and more
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Chapter 1. What Is a PostgreSQL Server?
Why program in the server?
About this book's code examples
Moving beyond simple functions
Managing related data with triggers
Auditing changes
Data cleaning
Custom sort orders
Programming best practices
Caching
Wrapping up – why program in the server?
Summary
Chapter 2. Server Programming Environments
Cost of acquisition
Availability of developers
Licensing
Predictability
Community
Procedural languages
Chapter 3. Your First PL/pgSQL Function
Why PL/pgSQL?
The structure of a PL/pgSQL function
Conditional expressions
Returning a record
Acting on the function's results
Chapter 4. Returning Structured Data
Sets and arrays
Returning sets
Using a set returning function
Functions based on views
OUT parameters and records
A summary of the RETURN SETOF variants
Returning cursors
Other ways to work with structured data
Chapter 5. PL/pgSQL Trigger Functions
Creating the trigger function
Working on a simple "Hey I'm called" trigger
The audit trigger
Disallowing DELETE
Disallowing TRUNCATE
Modifying the NEW record
The immutable fields trigger
Controlling when a trigger is called
Visibility
Variables passed to the PL/pgSQL TRIGGER function
Chapter 6. PostgreSQL Event Triggers
Use cases for creating event triggers
Creating event triggers
Creating an audit trail
Preventing schema changes
A roadmap of event triggers
Chapter 7. Debugging PL/pgSQL
Manual debugging with RAISE NOTICE
Visual debugging
Chapter 8. Using Unrestricted Languages
Are untrusted languages inferior to trusted ones?
Can you use untrusted languages for important functions?
Will untrusted languages corrupt the database?
Why untrusted?
Quick introduction to PL/Python
Thinking out of the "SQL database server" box
Chapter 9. Writing Advanced Functions in C
The simplest C function – return (a + b)
Adding functionality to add(int int)
Basic guidelines for writing C code
Error reporting from C functions
Running queries and calling PostgreSQL functions
Handling records as arguments or returned values
Fast capturing of database changes
Doing something at commit/rollback
Synchronizing between backends
Writing functions in C++
Additional resources for C
Chapter 10. Scaling Your Database with PL/Proxy
Creating a simple single-server chat
Dealing with success – splitting tables over multiple databases
Connection Pooling