Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
This branch is 2 commits behind PacktPublishing:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

PostgreSQL 11 Server Side Programming Quick Start Guide

PostgreSQL 11 Server Side Programming Quick Start Guide

This is the code repository for PostgreSQL 11 Server Side Programming Quick Start Guide, published by Packt.

Naming conventions

Each chapter in the book has a corresponding folder within the repository. Each folder contains a set of files named after the chapter number and the listing in the chapter: as an example the listing 3 of chapter 2 is placed in the folder Chapter02 with the name Chapter02_Listing03.sql, that is Chapter02/Chapter02_Listing03.sql.

What is this book about?

PostgreSQL is a rock-solid, scalable, and safe enterprise-level relational database. With a broad range of features and stability, it is ever increasing in popularity.This book shows you how to take advantage of PostgreSQL 11 features for server-side programming. Server-side programming enables strong data encapsulation and coherence.

This book covers the following exciting features:

  • Explore data encapsulation
  • Write stored procedures in different languages
  • Interact with transactions from within a function
  • Get to grips with triggers and rules
  • Create and manage custom data types

If you feel this book is for you, get your copy today!

Table of Contents

The book is organized in 10 chapters:

  • Chapter 1, Introduction to Server Side Programming;
  • Chapter 2, Query Tricks;
  • Chapter 3, The PL/pgSQL Language;
  • Chapter 4, Stored Procedures;
  • Chapter 5, PL/Perl and PL/Java;
  • Chapter 6, Triggers;
  • Chapter 7, Rules and the Query Rewriting System;
  • Chapter 8, Extensions;
  • Chapter 9, Intra-Process Communications;
  • Chapter 10, Custom Data Types;

The code contained in this repository is organized with regard to above table of contents.

Instructions and Navigations

All of the code is organized into folders, one per chapter, as for example Chapter02.

The code will look like the following:

ImgRes* new_ImgRes() {
  ImgRes* new_object = (ImgRes*) palloc( sizeof( ImgRes ) );
  new_object->h_px = 300;
  new_object->v_px = 300;
  new_object->dpi  = 96;
  return new_object;

char* to_string( ImgRes* object ){

Each source code file has a suffix that indicates the type of the file itself, mainly:

  • .sql means the file contain SQL statement(s);
  • .perl or .plperl means the file contains Perl 5 code;
  • .java means the file contains Java source code;
  • .output means the file contains text output of the execution of a SQL statement or another executable code.

Following is what you need for this book: This book is for database administrators, data engineers, and database engineers who want to implement advanced functionalities and master complex administrative tasks with PostgreSQL 11.

With the following software list you can run all code files present in the book (Chapters 1-10).

Software List

Chapter Software required OS recommended
1-10 PostgreSQL 11 Unix or Linux (Any)
4-6 Perl 5 (5.27.8 or higher) Unix or Linux (Any)
4-6 Java JDK (version 8, update 181 or higher) Unix or Linux (Any)
8 Python Unix or Linux (Any)
9-10 C Compiler Unix or Linux (Any)

Related products

Get to Know the Author

Luca has been passionate about computer science since the Commodore 64 era, and today holds a master's degree (with honors) and a PhD from the University of Modena and Reggio Emilia. He has written several research papers, technical articles, and book chapters. In 2011, he was named Adjunct Professor by the University of Nipissing. An avid Unix user, he is a strong advocate of open source, and in his free time he collaborates with a few projects. He met PostgreSQL back in release 7.3; he was a founder and former president of the Italian PostgreSQL Community (ITPUG), he talks regularly at technical conferences and events, and delivers professional training. In his teenage years, he was quite a proficient archer. He lives in Italy with his beautiful wife, son, and two (female) cats.

Suggestions and Feedback

Click here if you have any feedback or suggestions.


Published by Packt







No releases published


No packages published


  • PLpgSQL 42.3%
  • TSQL 28.9%
  • Java 16.5%
  • C 9.8%
  • Perl 0.9%
  • PLSQL 0.8%
  • Other 0.8%