Author: timbo
Date: Wed Jun 28 02:37:16 2006
New Revision: 6574

Modified:
   dbi/trunk/Changes
   dbi/trunk/DBI.pm
   dbi/trunk/lib/DBD/File.pm

Log:
Added $dbh->statistics_info thanks to Brandon Black.
Also fix DBI::SQL_TINYINT in (old) DBD::File thanks to Cosimo Streppone.


Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes   (original)
+++ dbi/trunk/Changes   Wed Jun 28 02:37:16 2006
@@ -4,11 +4,12 @@
 
 =cut
 
-XXX update DBD::File (as sub-module?) to match latest.
-
 =head2 Changes in DBI 1.52 (svn rev XXX),   XXX
 
+XXX update DBD::File (as sub-module?) to match latest.
+
   Fixed memory leak (16 bytes per sth) thanks to Doru Theodor Petrescu.
+  Added $dbh->statistics_info thanks to Brandon Black.
 
 =head2 Changes in DBI 1.51 (svn rev 6475),   6th June 2006
 

Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm    (original)
+++ dbi/trunk/DBI.pm    Wed Jun 28 02:37:16 2006
@@ -423,6 +423,7 @@
        primary_key_info=> { U =>[4,5,'$catalog, $schema, $table [, \%attr ]' 
],        O=>0x2200|0x0800 },
        primary_key     => { U =>[4,5,'$catalog, $schema, $table [, \%attr ]' 
],        O=>0x2200 },
        foreign_key_info=> { U =>[7,8,'$pk_catalog, $pk_schema, $pk_table, 
$fk_catalog, $fk_schema, $fk_table [, \%attr ]' ], O=>0x2200|0x0800 },
+       statistics_info => { U =>[6,7,'$catalog, $schema, $table, $unique_only, 
$quick, [, \%attr ]' ], O=>0x2200|0x0800 },
        type_info_all   => { U =>[1,1], O=>0x2200|0x0800 },
        type_info       => { U =>[1,2,'$data_type'], O=>0x2200 },
        get_info        => { U =>[2,2,'$info_type'], O=>0x2200|0x0800 },
@@ -4727,6 +4728,99 @@
 
 See also L</"Catalog Methods"> and L</"Standards Reference Information">.
 
+=item C<statistics_info>
+
+B<Warning:> This method is experimental and may change.
+
+  $sth = $dbh->statistics_info( $catalog, $schema, $table, $unique_only, 
$quick );
+
+Returns an active statement handle that can be used to fetch statistical
+information about a table and its indexes.
+
+The arguments don't accept search patterns (unlike L</table_info>).
+
+If the boolean argument $unique_only is true, only UNIQUE indexes will be
+returned in the result set, otherwise all indexes will be returned.
+
+If the boolean argument $quick is set, the actual statistical information
+columns (CARDINALITY and PAGES) will only be returned if they are readily
+available from the server, and might not be current.  Some databases may
+return stale statistics or no statistics at all with this flag set.
+
+For example:
+
+  $sth = $dbh->statistics_info( undef, $user, 'foo', 1, 1 );
+  $data = $sth->fetchall_arrayref;
+
+The statement handle will return at most one row per column name per index,
+plus at most one row for the entire table itself, ordered by NON_UNIQUE, TYPE,
+INDEX_QUALIFIER, INDEX_NAME, and ORDINAL_POSITION.
+
+Note: The support for the selection criteria, such as $catalog, is
+driver specific.  If the driver doesn't support catalogs and/or
+schemas, it may ignore these criteria.
+
+The statement handle returned has at least the following fields in the
+order shown below. Other fields, after these, may also be present.
+
+B<TABLE_CAT>: The catalog identifier.
+This field is NULL (C<undef>) if not applicable to the data source,
+which is often the case.  This field is empty if not applicable to the
+table.
+
+B<TABLE_SCHEM>: The schema identifier.
+This field is NULL (C<undef>) if not applicable to the data source,
+and empty if not applicable to the table.
+
+B<TABLE_NAME>: The table identifier.
+
+B<NON_UNIQUE>: Unique index indicator.
+Returns 0 for unique indexes, 1 for non-unique indexes
+
+B<INDEX_QUALIFIER>: Index qualifier identifier.
+The identifier that is used to qualify the index name when doing a
+C<DROP INDEX>; NULL (C<undef>) is returned if an index qualifier is not
+supported by the data source.
+If a non-NULL (defined) value is returned in this column, it must be used
+to qualify the index name on a C<DROP INDEX> statement; otherwise,
+the TABLE_SCHEM should be used to qualify the index name.
+
+B<INDEX_NAME>: The index identifier.
+
+B<TYPE>: The type of information being returned.  Can be any of the
+following values: 'table', 'btree', 'clustered', 'content', 'hashed',
+or 'other'.
+
+In the case that this field is 'table', all fields
+other than TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TYPE,
+CARDINALITY, and PAGES will be NULL (C<undef>).
+
+B<ORDINAL_POSITION>: Column sequence number (starting with 1).
+
+B<COLUMN_NAME>: The column identifier.
+
+B<ASC_OR_DESC>: Column sort sequence.
+C<A> for Ascending, C<D> for Descending, or NULL (C<undef>) if
+not supported for this index.
+
+B<CARDINALITY>: Cardinality of the table or index.
+For indexes, this is the number of unique values in the index.
+For tables, this is the number of rows in the table.
+If not supported, the value will be NULL (C<undef>).
+
+B<PAGES>: Number of storage pages used by this table or index.
+If not supported, the value will be NULL (C<undef>).
+
+B<FILTER_CONDITION>: The index filter condition as a string.
+If the index is not a filtered index, or it cannot be determined
+whether the index is a filtered index, this value is NULL (C<undef>).
+If the index is a filtered index, but the filter condition
+cannot be determined, this value is the empty string C<''>.
+Otherwise it will be the literal filter condition as a string,
+such as C<SALARY <= 4500>.
+
+See also L</"Catalog Methods"> and L</"Standards Reference Information">.
+
 =item C<tables>
 
   @names = $dbh->tables( $catalog, $schema, $table, $type );
@@ -6311,6 +6405,7 @@
   foreign_key_info
   primary_key_info
   table_info
+  statistics_info
 
 All catalog methods accept arguments in order to restrict the result sets.
 Passing C<undef> to an optional argument does not constrain the search for
@@ -7062,6 +7157,7 @@
  primary_key_info  SQLPrimaryKeys    Page 254
  table_info        SQLTables         Page 294
  type_info         SQLGetTypeInfo    Page 239
+ statistics_info   SQLStatistics
 
 For example, for ODBC information on SQLColumns you'd visit:
 

Modified: dbi/trunk/lib/DBD/File.pm
==============================================================================
--- dbi/trunk/lib/DBD/File.pm   (original)
+++ dbi/trunk/lib/DBD/File.pm   Wed Jun 28 02:37:16 2006
@@ -389,7 +389,7 @@
         $type == DBI::SQL_FLOAT()     ||
         $type == DBI::SQL_REAL()      ||
         $type == DBI::SQL_DOUBLE()    ||
-        $type == DBI::TINYINT())) {
+        $type == DBI::SQL_TINYINT())) {
        return $str;
     }
     if (!defined($str)) { return "NULL" }

Reply via email to