PGCon2010 - Final Release III

PGCon 2010
The PostgreSQL Conference

Speakers
Greg Smith
Schedule
Day Talks - 1 - 2010-05-20
Room DMS 1160
Start time 13:30
Duration 01:00
Info
ID 205
Event type Lecture
Track Hacking
Language used for presentation English

Exposing PostgreSQL Internals with User-Defined Functions

Easing into PostgreSQL Hacking

User-defined functions are one of the easiest ways to get started hacking on the PostgreSQL codebase and produce something useful in a short time. Watch a whole new trivial feature get added with one, and learn how to step over some of the more common confusing parts of the codebase along the way.

PostgreSQL's user-defined function (UDF) mechanism is useful for all sorts of things. You can add your own custom C code to the database, for performance or extensibility reasons. You can expose database internals that you wouldn't otherwise be able to access. And it's a great way to get started hacking on PostgreSQL with quick results.

This talk leads you through a quick tour of creating a UDF that exposes a useful bit of information about how you're using the shared_buffers cache on your system. Consider it a "hello, world" for writing a PostgreSQL patch that adds a tiny feature as a function. You'll learn some tricks for how to find useful code to borrow too. Knowing where some simple examples are at is most of the battle when getting started here.

The material is based on several conversations about the most confusing PostgreSQL hacking basics with those completely new to that area, in hopes that you won't have to get stuck on the same things they did. You'll need a basic understanding of coding in C or similar languages to follow the examples, but not any previous exposure to the PostgreSQL code.