Tim Bunce > PostgreSQL-PLPerl-Trace > PostgreSQL::PLPerl::Trace

Download:
PostgreSQL-PLPerl-Trace-1.001.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.001   Source  

NAME ^

PostgreSQL::PLPerl::Trace - Simple way to trace execution of Perl statements in PL/Perl

VERSION ^

version 1.001

SYNOPSIS ^

Load via a line in your plperlinit.pl file:

    use PostgreSQL::PLPerl::Trace;

Load via the PERL5OPT environment variable:

    $ PERL5OPT='-MPostgreSQL::PLPerl::Trace' pg_ctl ...

DESCRIPTION ^

Writes a line to the PostgreSQL log file for every PL/Perl statement executed. This can generate truly massive amounts of log data and also slows excution of PL/Perl code by at least a couple of orders of magnitude.

Why would you want to do this? Well, there are times when it's a simple and effective way to see what PL/Perl code is actually being executed.

This module is based on Devel::Trace but modified to work with PostgreSQL PL/Perl for both the plperlu language and, more significantly, for the plperl language as well. It also shows the subroutine name whenever execution moves from one subroutine to another.

ENABLING ^

In order to use this module you need to arrange for it to be loaded when PostgreSQL initializes a Perl interpreter.

Create a plperlinit.pl file in the same directory as your postgres.conf file, if it doesn't exist already.

In the plperlinit.pl file write the code to load this module:

    use PostgreSQL::PLPerl::Trace;

When it's no longer needed just comment it out by prefixing with a #.

PostgreSQL 8.x

Set the PERL5OPT before starting postgres, to something like this:

    PERL5OPT='-e "require q{plperlinit.pl}"'

The code in the plperlinit.pl should also include delete $ENV{PERL5OPT}; to avoid any problems with nested invocations of perl, e.g., via a plperlu function.

PostgreSQL 9.0

For PostgreSQL 9.0 you can still use the PERL5OPT method described above. Alternatively, and preferably, you can use the plperl.on_init configuration variable in the postgres.conf file.

    plperl.on_init='require q{plperlinit.pl};'

Alternative Method

It you're not already using the PERL5OPT environment variable to load a plperlinit.pl file, as described above, then you can use it as a quick way to load the module for ad-hoc use:

    $ PERL5OPT='-MPostgreSQL::PLPerl::Trace' pg_ctl ...

AUTHOR ^

Tim Bunce http://www.tim.bunce.name

Copyright (c) Tim Bunce, Ireland, 2010. All rights reserved. You may use and distribute on the same terms as Perl 5.10.1.

With thanks to http://www.TigerLead.com for sponsoring development.

syntax highlighting: