O'Reilly Open Source Convention
Books Safari Bookshelf Conferences O'Reilly Network

Arrow Home
Arrow Registration
Arrow Speakers
Arrow Keynotes
Arrow Tutorials
Arrow Sessions
Arrow At-a-Glance
Arrow Wiki
Arrow BOFs
Arrow Events
Arrow Exhibitors
Arrow Sponsors
Arrow Hotel/Travel
Arrow Venue Map
Arrow See & Do
Arrow Tips for
Arrow Press
Arrow Mail List



Power PostgreSQL: Extending the Database with C
Joseph Conway

Track: PostgreSQL
Date: Monday, July 26
Time: 1:45pm - 5:15pm
Location: Salon H


Discover how powerful PostgreSQL can be by developing your own user defined C functions, and deliver superior results to your customers. This tutorial will give you an understanding from start to finish with respect to writing user defined PostgreSQL C functions. It covers a wide range, from simple scalar-input/scalar-output functions, to more recent advanced features such as:

  • Returning composite (tuple) types
  • Returning sets (multiple rows)
  • Manipulating PostgreSQL arrays
  • Polymorphism
  • Tutorial outline:

    - Contrib build system
    * Makefile basics
    * Typical minimal file layout
    * Regression test

    - Functions returning one row

    * Calling Conventions: Version 0 vs Version 1
    + Function declaration
    + Function info macro

    * Handling arguments
    + PG_GETARG macros
    + scalar
    + decomposing arrays
    + decomposing composite (tuple) types
    + resolving polymorphic types

    * Handling return values
    + PG_RETURN macros
    + scalar
    + building arrays
    + building composite (tuple) types
    + resolving polymorphic types

    * Error handling

    * Memory allocation and contexts
    + special macros/functions
    + contexts

    * Data persistence
    + call-to-call
    + session

    * Complete examples
    + scalar
    + arrays
    + composite
    + polymorphic

    - Set Returning Functions

    * one-row-at-a-time api
    + overview
    + special macros/functions
    + first-call section
    + per-call section
    + memory contexts
    + composite return type considerations
    + complete example

    * returning a tuplestore
    + overview
    + special macros/functions
    + building a tuplestore
    + memory contexts
    + composite return type considerations
    + complete example

    O'Reilly Home | Privacy Policy

    © 2004, O'Reilly Media, Inc.