Re: DBI::DBD: attribute handling (outer/inner handles, $h-STORE vs. $h-{})

2004-12-17 Thread Steffen Goeldner
Tim Bunce wrote:
Actually it's only the first letter that matters (so foo_Bar is okay,
if you like that kind of thing :)
I've changed the text to read:
: Note the prefix Idrv_ in the attribute names: it is required that
: all your private attributes use a lowercase prefix unique to your driver.
: The DBI contains a registry of known driver prefixes and may one day
: warn about unknown attributes that don't have a registered prefix.
O.k., that's clear now.
Is STORE() responsible for checking/changing this or should the
connect() code above handle this?
I'm not quite sure what you're asking there. I presume you asking
about any invalid/misspelt driver-private attribute not just mixed
case ones.
Exactly! With the clarification above, my question is answered.
Steffen


Re: DBI::DBD: attribute handling (outer/inner handles, $h-STORE vs. $h-{})

2004-12-17 Thread Steffen Goeldner
Tim Bunce wrote:
I've added this:
[...]
Comments, or patches against subversion, most welcome.
Fixed this daVinci bug:
  -  my ($drh, $dbname, $user, $auth, $attr) = @_;
  +  my ($drh, $dr_dsn, $user, $auth, $attr) = @_;
as well as a few typos and the like.
Steffen
Index: lib/DBI/DBD.pm
===
--- lib/DBI/DBD.pm  (revision 633)
+++ lib/DBI/DBD.pm  (working copy)
@@ -622,7 +622,7 @@
 The Idriver method is the driver handle constructor. It's a
 reasonable example of how DBI implements its handles. There are three
 kinds: Bdriver handles (typically stored in C$drh; from now on
-called Cdrh of C$drh), Bdatabase handles (from now on called Cdbh or
+called Cdrh or C$drh), Bdatabase handles (from now on called Cdbh or
 C$dbh) and Bstatement handles (from now on called Csth or
 C$sth).
 
@@ -664,7 +664,7 @@
 interpreter:
 
   sub CLONE {
-undef $rdh;
+undef $drh;
   }
 
 =head3 The DBD::Driver::dr package
@@ -700,7 +700,7 @@
 
   # Process attributes from the DSN; we assume ODBC syntax
   # here, that is, the DSN looks like var1=val1;...;varN=valN
-  foreach my $var ( split /;/, $dbname ) {
+  foreach my $var ( split /;/, $dr_dsn ) {
   my ($attr_name, $attr_value) = split '=', $var, 2;
  return $drh-set_err(1, Can't parse DSN part '$var')
   unless defined $attr_value;
@@ -723,10 +723,10 @@
 
   # Assume you can attach to your database via drv_connect:
   my $connection = drv_connect($db, $host, $port, $user, $auth)
-  or return $drh-set_err(1, Can't connect to $dbname: ...);
+  or return $drh-set_err(1, Can't connect to $dr_dsn: ...);
 
   # create a 'blank' dbh (call superclass constructor)
-  my ($outer, $dbh) = DBI::_new_dbh($drh, { Name = $dbname });
+  my ($outer, $dbh) = DBI::_new_dbh($drh, { Name = $dr_dsn });
 
   $dbh-STORE('Active', 1 );
   $dbh-{drv_connection} = $connection;
@@ -775,7 +775,7 @@
 
   sub data_sources
   {
-  my($srh, $attr) = @_;
+  my($drh, $attr) = @_;
   my(@list) = ();
   # You need more sophisticated code than this to set @list...
   push @list, dbi:Driver:abc;
@@ -996,7 +996,7 @@
   my $dbh = $sth-{Database};
   $val = $dbh-quote($sth, $type);
   }
-  my $params = $sth-FETCH('drv_params');
+  my $params = $sth-{drv_params};
   $params-[$pNum-1] = $val;
   1;
   }
@@ -1009,7 +1009,7 @@
   $sth-finish if $sth-FETCH('Active');
 
   my $params = (@bind_values) ?
-  [EMAIL PROTECTED] : $sth-FETCH('drv_params');
+  [EMAIL PROTECTED] : $sth-{drv_params};
   my $numParam = $sth-FETCH('NUM_OF_PARAMS');
   return $sth-set_err(1, Wrong number of parameters)
   if @$params != $numParam;
@@ -1028,8 +1028,8 @@
 There are a number of things you should note here.
 We setup the NUM_OF_FIELDS attribute
 here, because this is essential for Ibind_columns to work.
-We use attribute I$sth-{'Statement'} which we created
-within Iprepare. The attribute I$sth-{'Database'}, which is
+We use attribute C$sth-Egt{Statement} which we created
+within Iprepare. The attribute C$sth-Egt{Database}, which is
 nothing else than the Idbh, was automatically created by DBI.
 
 Finally note that (as specified in the DBI specification) we return the
@@ -1048,10 +1048,10 @@
   sub fetchrow_arrayref
   {
   my ($sth) = @_;
-  my $data = $sth-FETCH('drv_data');
+  my $data = $sth-{drv_data};
   my $row = shift @$data;
   if (!$row) {
-  $sth-STORE(Active = 0); # mark as no longer active 
+  $sth-STORE(Active = 0); # mark as no longer active
   return undef;
   }
   if ($sth-FETCH('ChopBlanks')) {
@@ -1061,7 +1061,7 @@
   }
   *fetch = \fetchrow_arrayref; # required alias for fetchrow_arrayref
 
-  sub rows { shift-FETCH('drv_rows') }
+  sub rows { shift-{drv_rows} }
 
 Note the use of the method I_set_fbav: This is required so that
 Ibind_col and Ibind_columns work.


Re: DBD::ExampleP: attribute handling (outer/inner handles, $h-STORE vs. $h-{})

2004-12-17 Thread Tim Bunce
Thanks, applied.

Tim.

On Fri, Dec 17, 2004 at 11:33:24AM +0100, Steffen Goeldner wrote:
 Changed DBD::ExampleP to reflect the recent changes to DBI::DBD.
 
 
 Steffen

 Index: lib/DBD/ExampleP.pm
 ===
 --- lib/DBD/ExampleP.pm   (revision 633)
 +++ lib/DBD/ExampleP.pm   (working copy)
 @@ -58,13 +58,10 @@
  
  sub connect { # normally overridden, but a handy default
  my($drh, $dbname, $user, $auth)= @_;
 -my($this) = DBI::_new_dbh($drh, {
 - 'Name' = $dbname,
 - 'User' = $user,
 - examplep_get_info = {},
 - });
 - $this-STORE(Active = 1);
 -$this;
 +my ($outer, $dbh) = DBI::_new_dbh($drh, { Name = $dbname });
 +$dbh-STORE('Active', 1);
 +$dbh-{examplep_get_info} = {};
 +return $outer;
  }
  
  sub data_sources {
 @@ -97,7 +94,7 @@
   # No we have DBI::DBM etc ExampleP should be deprecated
   }
  
 - my ($outer, $inner) = DBI::_new_sth($dbh, {
 + my ($outer, $sth) = DBI::_new_sth($dbh, {
   'Statement' = $statement,
   }, ['example implementors private data '.__PACKAGE__]);
  
 @@ -109,7 +106,7 @@
  
   $outer-STORE('NUM_OF_FIELDS' = scalar(@fields));
  
 - $inner-{'dbd_ex_dir'} = $dir if defined($dir)  $dir !~ /\?/;
 + $sth-{dbd_ex_dir} = $dir if defined($dir)  $dir !~ /\?/;
   $outer-STORE('NUM_OF_PARAMS' = ($dir) ? $dir =~ tr/?/?/ : 0);
  
   if (@fields) {



Re: DBI::DBD: Other statement methods

2004-12-17 Thread Tim Bunce
On Fri, Dec 17, 2004 at 02:15:57PM +0100, Steffen Goeldner wrote:
 
 P.S.: This was my last patch this year.

Thanks, applied.

   I wish all a Merry Christmas and a Happy New Year!

Thanks Steffen. And many thanks for all your well-considered
and well-presented patches.

Tim.


Re: DBI::DBD: attribute handling (outer/inner handles, $h-STORE vs. $h-{})

2004-12-17 Thread Tim Bunce
On Thu, Dec 16, 2004 at 10:58:35AM +0100, Steffen Goeldner wrote:
 However, it's placed below the connect() method:
 
   
 http://search.cpan.org/~timb/DBI-1.46/lib/DBI/DBD.pm#The_database_handle_constructor
 
 where we have an outer handle by way of an exception!
 Instead of changing the nice description, I'd rather change the
 example code (see attached patch). Advantages that accrued:
 
  - Now, we have the inner handle the text speaks about.
  - The example is shorter.
  - The example shows both, the STORE method and direct hash access.
  - The example shows a realistic DBI attribute ('Active') instead of
whatever gets extracted from DSN (and may cause troubles in STORE).

(STORE should always be able to handle any kind of attribute,
avoiding it is purely an optimization. Less relevant in these days
of gigahertz processors.)

  - The example shows a realistic driver specific attribute.
  - The examples are more consistent ($dbh is always the inner handle).

Thanks, applied.

Tim.