DBD-Pg

 view release on metacpan or  search on metacpan

Pg.h  view on Meta::CPAN

#define THEADER_slow      (TFPREFIX_slow) ? "dbdpg: " : ""

#define TRC (void)PerlIO_printf

/* Fancy stuff for tracing of commonly used libpq functions */
#define TRACE_XX                   if (TLIBPQ_slow) TRC(DBILOGFP,
/* XXX every use of every one of these costs at least one call to DBIS
 * and possibly +1 for DBILOGFP and another for THEADER_slow!
 * A better approach may be something like DBD::Oracle's
 * http://cpansearch.perl.org/src/PYTHIAN/DBD-Oracle-1.42/ocitrace.h
 * #define PGfooBar_log_stat(imp_xxh, stat, a,b,c) ... where imp_xxh
 * is used to determine the logging and stat holds the result.
 * That makes the code uncluttered and gives good flexibility.
 */
#define TRACE_PQBACKENDPID         TRACE_XX "%sPQbackendPID\n",          THEADER_slow)
#define TRACE_PQCANCEL             TRACE_XX "%sPQcancel\n",              THEADER_slow)
#define TRACE_PQCLEAR              TRACE_XX "%sPQclear\n",               THEADER_slow)
#define TRACE_PQCMDSTATUS          TRACE_XX "%sPQcmdStatus\n",           THEADER_slow)
#define TRACE_PQCMDTUPLES          TRACE_XX "%sPQcmdTuples\n",           THEADER_slow)
#define TRACE_PQCONNECTDB          TRACE_XX "%sPQconnectdb\n",           THEADER_slow)
#define TRACE_PQCONSUMEINPUT       TRACE_XX "%sPQconsumeInput\n",        THEADER_slow)

Pg.pm  view on Meta::CPAN

number of placeholders as your prepared statement. Example:

  $dbh->do('PREPARE mystat AS SELECT COUNT(*) FROM pg_class WHERE reltuples < ?');
  $sth = $dbh->prepare('SELECT ?');
  $sth->bind_param(1, 1, SQL_INTEGER);
  $sth->{pg_prepare_name} = 'mystat';
  $sth->execute(123);

The above will run the equivalent of this query on the backend:

  EXECUTE mystat(123);

which is the equivalent of:

  SELECT COUNT(*) FROM pg_class WHERE reltuples < 123;

You can force DBD::Pg to send your query directly to the server by adding
the L<pg_direct|/pg_direct (boolean)> attribute to your prepare call. This is not recommended,
but is added just in case you need it.

=head4 B<Placeholders>

t/dbdpg_test_setup.pl  view on Meta::CPAN

                print {$fh} "This is a test directory for DBD::Pg and may be removed\n";
                print {$fh} "You may want to ensure the postmaster has been stopped first.\n";
                print {$fh} "Check the data/postmaster.pid file\n";
                close $fh or die qq{Could not close "$readme": $!\n};
            }

            ## Likely candidates for running this
            my @userlist = (qw/postgres postgresql pgsql _postgres/);

            ## Start with whoever owns this file, unless it's us
            my $username = getpwuid ((stat($0))[4]);
            unshift @userlist, $username if defined $username and $username ne getpwent;

            my %doneuser;
            for (@userlist) {
                $testuser = $_;
                next if $doneuser{$testuser}++;
                $uid = (getpwnam $testuser)[2];
                next if !defined $uid;

                next unless chown $uid, -1, $testdir;



( run in 0.460 second using v1.01-cache-2.11-cpan-49f99fa48dc )