Author: turnstep
Date: Sat Jun 23 11:06:36 2007
New Revision: 9674

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/Pg.pm
   DBD-Pg/trunk/t/03dbmethod.t
   DBD-Pg/trunk/t/03smethod.t

Log:
Add private_attribute_info() methods and tests.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes        (original)
+++ DBD-Pg/trunk/Changes        Sat Jun 23 11:06:36 2007
@@ -1,12 +1,13 @@
 ('GSM' is Greg Sabino Mullane, [EMAIL PROTECTED])
 
 1.50
+       - Add private_attribute_info() method. [GSM]
        - Add SQL_INTERVAL and others to types.c [GSM]
-    - Change $dbh->{Name} to return the entire DSN string, minus the 
-      'dbi:Pg:' part. Thanks to Mark Stosberg for the idea. [GSM]
+       - Change $dbh->{Name} to return the entire DSN string, minus the 
+               'dbi:Pg:' part. Thanks to Mark Stosberg for the idea. [GSM]
        - Add $dbh->{pg_placeholder_dollaronly} to allow '?' and other symbols 
-         to be used in prepared statements without getting interpreted as 
-         placeholders, i.e. the geometric operator '?#' (CPAN bug #24124) [GSM]
+               to be used in prepared statements without getting interpreted 
as 
+               placeholders, i.e. the geometric operator '?#' (CPAN bug 
#24124) [GSM]
        - Use prepare_cached in last_insert_id function. (CPAN bug #24313)
        - Switch from cvs to subversion. Switch from gborg to perl.org.
        - Fix pg_description join in table_info(). [Max Cohan [EMAIL PROTECTED]

Modified: DBD-Pg/trunk/Pg.pm
==============================================================================
--- DBD-Pg/trunk/Pg.pm  (original)
+++ DBD-Pg/trunk/Pg.pm  Sat Jun 23 11:06:36 2007
@@ -167,6 +167,12 @@
                $dbh;
        }
 
+       sub private_attribute_info {
+               return {
+               };
+       }
+
+
 }
 
 
@@ -177,7 +183,6 @@
 
        use strict;
 
-
        sub prepare {
                my($dbh, $statement, @attribs) = @_;
 
@@ -1552,6 +1557,17 @@
 
                 return $ans;
        } # end of get_info
+
+       sub private_attribute_info {
+               return {
+                               pg_bool_tf                => undef,
+                               pg_enable_utf8            => undef,
+                               pg_errorlevel             => undef,
+                               pg_prepare_now            => undef,
+                               pg_placeholder_dollaronly => undef,
+                               pg_server_prepare         => undef,
+               };
+       }
 }
 
 
@@ -1587,8 +1603,33 @@
                $$hash_of_arrays{$p_id} = $value_array;
                return $sth->bind_param($p_id, '', $attr) if $attr; ## This is 
the big change so -w does not complain
                1;
-       }
+       } ## end bind_param_array
 
+       sub private_attribute_info {
+               return {
+                               pg_bool_tf                => undef,
+                               pg_db                     => undef,
+                               pg_default_port           => undef,
+                               pg_enable_utf8            => undef,
+                               pg_errorlevel             => undef,
+                               pg_host                   => undef,
+                               pg_INV_READ               => undef,
+                               pg_INV_WRITE              => undef,
+                               pg_lib_version            => undef,
+                               pg_options                => undef,
+                               pg_pass                   => undef,
+                               pg_pid                    => undef,
+                               pg_pid_number             => undef,
+                               pg_placeholder_dollaronly => undef,
+                               pg_port                   => undef,
+                               pg_prepare_now            => undef,
+                               pg_protocol               => undef,
+                               pg_server_prepare         => undef,
+                               pg_server_version         => undef,
+                               pg_socket                 => undef,
+                               pg_user                   => undef,
+               };
+    }
 
 } ## end st section
 
@@ -1942,6 +1983,14 @@
 
 =back
 
+=item private_attribute_info
+
+  $hashref = $dbh->private_attribute_info();
+  $hashref = $sth->private_attribute_info();
+
+Supported by this driver as proposed by DBI.
+
+
 =back
 
 =head1 ATTRIBUTES COMMON TO ALL HANDLES

Modified: DBD-Pg/trunk/t/03dbmethod.t
==============================================================================
--- DBD-Pg/trunk/t/03dbmethod.t (original)
+++ DBD-Pg/trunk/t/03dbmethod.t Sat Jun 23 11:06:36 2007
@@ -18,7 +18,7 @@
 $|=1;
 
 if (defined $ENV{DBI_DSN}) {
-       plan tests => 198;
+       plan tests => 200;
 }
 else {
        plan skip_all => 'Cannot run test unless DBI_DSN is defined. See the 
README file';
@@ -898,11 +898,11 @@
 #
 
 my %quotetests = (
-                                                                       q{0} => 
q{'0'},
-                                                                       q{Ain't 
misbehaving } => q{'Ain''t misbehaving '},
-                                                                       NULL => 
q{'NULL'},
-                                                                       "" => 
q{''},
-                                                                );
+       q{0} => q{'0'},
+       q{Ain't misbehaving } => q{'Ain''t misbehaving '},
+       NULL => q{'NULL'},
+       "" => q{''},
+);
 
 for (keys %quotetests) {
        $result = $dbh->quote($_);
@@ -1103,6 +1103,25 @@
 $dbh->rollback();
 
 #
+# Test of the "private_attribute_info" database handle method
+#
+
+SKIP: {
+       if ($DBI::VERSION < 1.54) {
+               skip "DBI must be at least version 1.54 to test 
private_attribute_info", 2;
+       }
+
+       my $private = $dbh->private_attribute_info();
+       my ($valid,$invalid) = (0,0);
+       for my $name (keys %$private) {
+               $name =~ /^pg_\w+/ ? $valid++ : $invalid++;
+       }
+       ok($valid >= 1, qq{DB handle method "private_attribute_info" returns at 
least one record});
+       is($invalid, 0, qq{DB handle method "private_attribute_info" returns 
only internal names});
+
+}
+
+#
 # Test of the "ping" database handle method
 #
 

Modified: DBD-Pg/trunk/t/03smethod.t
==============================================================================
--- DBD-Pg/trunk/t/03smethod.t  (original)
+++ DBD-Pg/trunk/t/03smethod.t  Sat Jun 23 11:06:36 2007
@@ -13,7 +13,7 @@
 $|=1;
 
 if (defined $ENV{DBI_DSN}) {
-       plan tests => 55;
+       plan tests => 57;
 }
 else {
        plan skip_all => 'Cannot run test unless DBI_DSN is defined. See the 
README file';
@@ -380,6 +380,28 @@
 else {
        is ($result, "S8006", qq{Statement handle method "state" returns 
expected code (old servers)});
 }
+
+#
+# Test of the statement handle method "private_attribute_info"
+#
+
+SKIP: {
+       if ($DBI::VERSION < 1.54) {
+               skip "DBI must be at least version 1.54 to test 
private_attribute_info", 2;
+       }
+
+       $sth = $dbh->prepare("SELECT 123");
+       my $private = $sth->private_attribute_info();
+       my ($valid,$invalid) = (0,0);
+       for my $name (keys %$private) {
+               $name =~ /^pg_\w+/ ? $valid++ : $invalid++;
+       }
+       ok($valid >= 1, qq{Statement handle method "private_attribute_info" 
returns at least one record});
+       is($invalid, 0, qq{Statement handle method "private_attribute_info" 
returns only internal names});
+       $sth->finish();
+}
+
+
 $dbh->rollback();
 
 $dbh->disconnect();

Reply via email to