Database Reference
In-Depth Information
PL/pgSQL also has a dirty little secret. The PostgreSQL developers don't want you
to know that it is a full-fledged SQL development language, capable of doing pretty
much anything within the PostgreSQL database.
Why is that a secret? For years, PostgreSQL did not claim to have stored proced-
ures. PL/pgSQL functions were originally designed to return scalar values and were
intended for simple mathematical tasks and trivial string manipulation.
Over the years, PL/pgSQL grew a rich set of control structures and gained the ability
to be used by triggers, operators, and indexes. In the end, the developers were
grudgingly forced to admit that they had a complete stored procedure development
system on their hands.
Along the way, the goal of PL/pgSQL changed from simplistic scalar functions to
providing access to all of the PostgreSQL system internals with full control struc-
ture. The full list of what is available in the current version is provided at ht-
tp://www.postgresql.org/docs/current/static/plpgsql-overview.html .
Today, some of the benefits of using PL/pgSQL are:
• It is easy to use
• It is available by default on most deployments of PostgreSQL
• It is optimized for performance of data intensive tasks
In addition to PL/pgSQL, PostgreSQL also allows many other languages to be
plugged in to the database, some of which we will cover in this topic. You may also
choose to write your functions in Perl, Python, PHP, bash, and a host of other lan-
guages, but they will likely need to be added to your instance of PostgreSQL.
Search WWH ::




Custom Search