GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DBIAgent::Helper(3) User Contributed Perl Documentation DBIAgent::Helper(3)

POE::Component::DBIAgent::Helper - DBI Query Helper for DBIAgent

 use Socket qw/:crlf/;
 use POE qw/Filter::Line Wheel::Run Component::DBIAgent::Helper/;

 sub _start {
     my $helper = POE::Wheel::Run ->new(
             Program     => sub {
                 POE::Component::DBIAgent::Helper->run($self->{dsn},
                                                       $self->{queries}
                                                      );
             },
             StdoutEvent => 'db_reply',
             StderrEvent => 'remote_stderr',
             ErrorEvent  => 'error',
             StdinFilter => POE::Filter::Line->new(),
             StdoutFilter => POE::Filter::Line->new( Literal => CRLF),
             StderrFilter => POE::Filter::Line->new(),
            )
      or carp "Can't create new DBIAgent::Helper: $!\n";

 }

 sub query {
      my ($self, $query, $package, $state, @rest) = @_;

      $self->{helper}->put(join '|', $query, $package, $state, @rest);
 }

 sub db_reply {
    my ($kernel, $self, $heap, $input) = @_[KERNEL, OBJECT, HEAP, ARG0];

    # $input is either the string 'EOF' or a Storable object.

 }

This is our helper routine for DBIAgent. It accepts queries on STDIN, and returns the results on STDOUT. Queries are returned on a row-by-row basis, followed by a row consisting of the string 'EOF'.

Each row is the return value of $sth->fetch, which is an arrayref. This row is then passed to Storable for transport, and printed to STDOUT. HOWEVER, Storable uses newlines ("\n") in its serialized strings, so the Helper is designed to use the "network newline" pair CR LF as the line terminator for STDOUT.

When fetch() returns undef, one final row is returned to the calling state: the string 'EOF'. Sessions should test for this value FIRST when being invoked with input from a query.

The Helper has one public subroutine, called "run()", and is invoked with two parameters:
The DSN
An arrayref of parameters to pass to DBI->connect (usually a dsn, username, and password).
The Queries.
A hashref of the form Query_Name => "$SQL". See POE::Component::DBIAgent for details.

I have NO idea what to do about handling signals intelligently. Specifically, under some circumstances, Oracle will refuse to acknowledge SIGTERM (presumably since its libraries are non-reentrant) so sometimes SIGKILL is required to terminate a Helper process.

This module has been fine-tuned and packaged by Rob Bloodgood <robb@empire2.com>. However, most of the code came directly from Fletch <fletch@phydeaux.org>, either directly (Po:Co:DBIAgent:Queue) or via his ideas. Thank you, Fletch!

However, I own all of the bugs.

This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

2004-09-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.