Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBIx-Connector CPAN distribution.

Report information
The Basics
Id: 62795
Status: rejected
Priority: 0/
Queue: DBIx-Connector

People
Owner: Nobody in particular
Requestors: darren [...] DarrenDuncan.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: darren [...] darrenduncan.net
Subject: want DBIx::Connector post-connect hooks
Date: Sat, 06 Nov 2010 23:16:00 -0700
To: "David E. Wheeler" <david [...] kineticode.com>, bug-dbix-connector [...] rt.cpan.org
From: Darren Duncan <darren [...] darrenduncan.net>
Hello David, I have been using DBIx::Connector for a few months now, and it occurs to me that my usage may be vulnerable to breaking if DBIx::Connector ever has to reopen a database connection. For context, here is the setup code that I currently use to create my DBIx::Connector object; it is within a wrapper class of my own: my $dsn = sprintf( q{dbi:Pg:dbname=%s;host=%s;port=%s}, $process->db_name(), $process->db_host(), $process->db_port() ); my $dbc = DBIx::Connector->new( $dsn, $process->db_user(), $process->db_pass(), { 'RaiseError' => 1, 'AutoCommit' => 1 }, ); my $dbh = $dbc->dbh(); $dbh->{pg_bool_tf} = 0; # 0 is default $dbh->{pg_server_prepare} = 1; # 1 is default $dbh->{pg_placeholder_dollaronly} = 1; # 0 is default $dbh->{pg_enable_utf8} = 1; # 0 is default $process->_sql_exec( $dbh, q{ SET extra_float_digits TO 3; }, [] ); $process->_sql_exec( $dbh, q{ SET datestyle TO 'ISO, YMD'; }, [] ); $process->_sql_exec( $dbh, q{ SET intervalstyle TO 'postgres'; }, [] ); $process->_sql_exec( $dbh, q{ SET timezone TO 'UTC'; }, [] ); The problem concerns the extra DBMS client environment setup that is done at the start of a connection, which the normal code expects to be in place. If DBIx::Connector has to reconnect to a database, I assume the details provided to new() will be reapplied, but I imagine that everything I did after isn't. If that is true, then can you please either add, or tell me about existing, post-connect-hooks on the DBIx::Connector object such that I can provide it a Perl anonymous subroutine reference which DBIx::Connector would execute any time it makes a connection (including the first time, so I assume it would be another argument for "new") so that any client setup can be transparently done? This subroutine would of course need to be given the DBIx::Connector object as an argument and/or that be provided in $_, as you feel is appropriate. Hopefully this is a quick and easy thing to do. Thank you in advance. -- Darren Duncan
Subject: Re: [rt.cpan.org #62795] want DBIx::Connector post-connect hooks
Date: Sun, 7 Nov 2010 11:44:43 -0800
To: bug-DBIx-Connector [...] rt.cpan.org
From: "David E. Wheeler" <david [...] kineticode.com>
On Nov 6, 2010, at 11:16 PM, darren@DarrenDuncan.net via RT wrote: Show quoted text
> If that is true, then can you please either add, or tell me about existing, > post-connect-hooks on the DBIx::Connector object such that I can provide it a > Perl anonymous subroutine reference which DBIx::Connector would execute any time > it makes a connection (including the first time, so I assume it would be another > argument for "new") so that any client setup can be transparently done? This > subroutine would of course need to be given the DBIx::Connector object as an > argument and/or that be provided in $_, as you feel is appropriate.
http://justatheory.com/computers/databases/postgresql/execute-on-select.html
Subject: Re: [rt.cpan.org #62795] want DBIx::Connector post-connect hooks
Date: Mon, 08 Nov 2010 12:26:00 -0800
To: bug-DBIx-Connector [...] rt.cpan.org
From: Darren Duncan <darren [...] darrenduncan.net>
David Wheeler via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=62795 > > > On Nov 6, 2010, at 11:16 PM, darren@DarrenDuncan.net via RT wrote: >
>> If that is true, then can you please either add, or tell me about existing, >> post-connect-hooks on the DBIx::Connector object such that I can provide it a >> Perl anonymous subroutine reference which DBIx::Connector would execute any time >> it makes a connection (including the first time, so I assume it would be another >> argument for "new") so that any client setup can be transparently done? This >> subroutine would of course need to be given the DBIx::Connector object as an >> argument and/or that be provided in $_, as you feel is appropriate.
> > http://justatheory.com/computers/databases/postgresql/execute-on-select.html
David, thank you. Yes, that is a much better solution. my $dsn = sprintf( q{dbi:Pg:dbname=%s;host=%s;port=%s}, $process->db_name(), $process->db_host(), $process->db_port() ); my $dbc = DBIx::Connector->new( $dsn, $process->db_user(), $process->db_pass(), { RaiseError => 1, AutoCommit => 1, Callbacks => { connected => sub { my ($dbh) = @_; $process->_do_post_connect( $dbh ); }, }, }, ); Change request retracted. -- Darren Duncan