Hello community,
here is the log from the commit of package perl-DBD-mysql
checked in at Sat Mar 3 14:32:59 CET 2007.
--------
--- perl-DBD-mysql/perl-DBD-mysql.changes 2007-01-10 14:29:16.000000000 +0100
+++ /mounts/work_src_done/STABLE/perl-DBD-mysql/perl-DBD-mysql.changes 2007-03-02 15:49:24.000000000 +0100
@@ -1,0 +2,9 @@
+Fri Mar 2 15:46:31 CET 2007 - anicka@suse.cz
+
+- update to 4.002
+ * Rewrote table_info method to support all arguments
+ * Add mysql_is_auto_increment to results of column_info().
+ * Add implementation of foreign_key_info()
+ * bugfixes
+
+-------------------------------------------------------------------
Old:
----
DBD-mysql-4.001.tar.bz2
New:
----
DBD-mysql-4.002.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-DBD-mysql.spec ++++++
--- /var/tmp/diff_new_pack.uO7705/_old 2007-03-03 14:32:41.000000000 +0100
+++ /var/tmp/diff_new_pack.uO7705/_new 2007-03-03 14:32:41.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package perl-DBD-mysql (Version 4.001)
+# spec file for package perl-DBD-mysql (Version 4.002)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -20,7 +20,7 @@
Requires: perl-DBI perl-Data-ShowTable
Requires: perl = %{perl_version}
Autoreqprov: on
-Version: 4.001
+Version: 4.002
Release: 1
Summary: Interface to the MySQL database
Group: Development/Libraries/Perl
@@ -62,7 +62,13 @@
%{perl_vendorarch}/DBD
/var/adm/perl-modules/perl-DBD-mysql
-%changelog -n perl-DBD-mysql
+%changelog
+* Fri Mar 02 2007 - anicka@suse.cz
+- update to 4.002
+ * Rewrote table_info method to support all arguments
+ * Add mysql_is_auto_increment to results of column_info().
+ * Add implementation of foreign_key_info()
+ * bugfixes
* Tue Jan 09 2007 - anicka@suse.cz
- update to 4.001
* Fix handling of unsigned integer values in result sets when
++++++ DBD-mysql-4.001.tar.bz2 -> DBD-mysql-4.002.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/ChangeLog new/DBD-mysql-4.002/ChangeLog
--- old/DBD-mysql-4.001/ChangeLog 2007-01-08 01:38:55.000000000 +0100
+++ new/DBD-mysql-4.002/ChangeLog 2007-03-01 23:34:46.000000000 +0100
@@ -1,4 +1,32 @@
-<unreleased> Jim Winstead Patrick Galbraith (4.001)
+2007-02-24 Patrick Galbraith Jim Winstead (4.002)
+* Rewrote table_info method to support all arguments (previously it would
+ only ever return all of the tables in the current database, no matter what
+ was specified)
+* Fixed version to be a string, which was previously a float, which caused
+ problems for certain locales
+* Fixed bug #23974. $dbh->column_info now returns empty arrayref upon table not
+ existing. Much thanks to Tim Bunce for help fixing the problem in mysql.pm
+ vs. dbdimp.c
+* Removed #ifdefs for do error (sqlstate being passed as last arg depending on
+ version)
+* Fixed insertid test to work with auto_increment_increment replication setup.
+* Patch from Tim Bunce fixing do() not set $dbh->{Statement} attribute,
+ which prevented DBD::Profile from giving correct results for calls to do()
+ and causing ShowErrorStatement to possibly report the wrong statement in the
+ error message
+* Patch from Tim Bunce clearing out the sth attribute cache when switching
+ between result, sets which prevented the adjustedment of NUM_OF_FIELDS
+* Cleanup of several unused variables
+* Added support for wildcards in last argument of column_info().
+* Add mysql_is_auto_increment to results of column_info(). (Bug #26603,
+ original patch from Dave Rolsky)
+* Return the correct table type for both tables and views from the table_info()
+ method. (Bug #26603, original patch from Dave Rolsky)
+* Add implementation of foreign_key_info() (Bug #26604, original patch from
+ Dave Rolsky, and final implementation based on Connector/J code)
+
+
+2007-1-8 Jim Winstead Patrick Galbraith (4.001)
* Fix handling of unsigned integer values in result sets when using
server-side prepared statements (they were not retrieved at all).
* Fix handling of signed integer values when using server-side prepared
@@ -61,6 +89,10 @@
* Added multiple fixes to dbd_st_prepare which fixed variable overwrite
and unset increment counter. Also improved loop which checks statements
for presence of "LIMIT" by using a pointer as opposed to char array
+* Added patch for SSL Verify Certificate (Thanks Eric Chen!)
+* Added multiple fixes to dbd_st_prepare which fixed variable overwrite
+ and unset increment counter. Also improved loop which checks statements
+ for presence of "LIMIT" by using a pointer as opposed to char array
increment variable. These errors were showing up in OpenBSD and other
Unixen (which I think all BSD-based) (Thanks to Kyle George!)
* Added fix to Makefile.PL to obtain correct build flags on VMS
@@ -996,7 +1028,7 @@
* lib/Msql/Statement.pm: Fixed use of Msql::TEXT_TYPE without
checking whether we are running Msql 1.
-$Id: ChangeLog 8518 2007-01-06 20:48:33Z capttofu $
+$Id: ChangeLog 9188 2007-03-01 21:13:52Z jimw $
DBD::mysql for DBI - Written by Jochen Wiedmann
@@ -1253,10 +1285,6 @@
24/11/95:13:01 Added 'NumRows' method to statement handles to return the
number of rows returned ( or affected ) by a statement.o
- pre-release distributed to ANDK
-
-25/11/95:09:20 Real release released! No major problems reported.
-
30/12/95:18:10 Altered mSQL.pm to allow for hostname:port style connections
to known remote port machines. Sets ENV var since the
msqlConnect API call doesn't support port arguments.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/dbdimp.c new/DBD-mysql-4.002/dbdimp.c
--- old/DBD-mysql-4.001/dbdimp.c 2007-01-08 01:39:05.000000000 +0100
+++ new/DBD-mysql-4.002/dbdimp.c 2007-03-01 16:47:26.000000000 +0100
@@ -8,7 +8,7 @@
* You may distribute this under the terms of either the GNU General Public
* License or the Artistic License, as specified in the Perl README file.
*
- * $Id: dbdimp.c 8519 2007-01-06 23:39:24Z jimw $
+ * $Id: dbdimp.c 9183 2007-03-01 15:47:39Z capttofu $
*/
@@ -438,11 +438,10 @@
bool bind_type_guessing)
{
- int rc;
char *salloc, *statement_ptr;
- char *statement_ptr_end, testchar, *ptr, *valbuf;
+ char *statement_ptr_end, *ptr, *valbuf;
char *cp, *end;
- int alen, i, j;
+ int alen, i;
int slen= *slen_ptr;
int limit_flag= 0;
STRLEN vallen;
@@ -576,7 +575,6 @@
else
{
int is_num = FALSE;
- int c;
valbuf= SvPV(ph->value, vallen);
if (valbuf)
@@ -1267,11 +1265,7 @@
*
**************************************************************************/
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
void do_error(SV* h, int rc, const char* what, const char* sqlstate)
-#else
-void do_error(SV* h, int rc, const char* what)
-#endif
{
D_imp_xxh(h);
STRLEN lna;
@@ -1826,12 +1820,7 @@
if (!my_login(dbh, imp_dbh))
{
do_error(dbh, mysql_errno(&imp_dbh->mysql),
- mysql_error(&imp_dbh->mysql)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,mysql_sqlstate(&imp_dbh->mysql));
-#else
- );
-#endif
+ mysql_error(&imp_dbh->mysql) ,mysql_sqlstate(&imp_dbh->mysql));
return FALSE;
}
@@ -1877,10 +1866,7 @@
#endif
{
do_error(dbh, mysql_errno(&imp_dbh->mysql), mysql_error(&imp_dbh->mysql)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,mysql_sqlstate(&imp_dbh->mysql)
-#endif
- );
+ ,mysql_sqlstate(&imp_dbh->mysql));
return FALSE;
}
}
@@ -1908,22 +1894,13 @@
#endif
{
do_error(dbh, mysql_errno(&imp_dbh->mysql),
- mysql_error(&imp_dbh->mysql)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,mysql_sqlstate(&imp_dbh->mysql));
-#else
- );
-#endif
+ mysql_error(&imp_dbh->mysql) ,mysql_sqlstate(&imp_dbh->mysql));
return FALSE;
}
}
else
do_error(dbh, JW_ERR_NOT_IMPLEMENTED,
- "Rollback ineffective because transactions are not available"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL
-#endif
- );
+ "Rollback ineffective because transactions are not available" ,NULL);
return TRUE;
}
@@ -2048,12 +2025,7 @@
#else
if (mysql_rollback(&imp_dbh->mysql))
#endif
- do_error(dbh, TX_ERR_ROLLBACK,"ROLLBACK failed"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(dbh, TX_ERR_ROLLBACK,"ROLLBACK failed" ,NULL);
}
dbd_db_disconnect(dbh, imp_dbh);
}
@@ -2118,7 +2090,7 @@
/* Setting autocommit will do a commit of any pending statement */
if (mysql_real_query(&imp_dbh->mysql, "SET AUTOCOMMIT=1", 16))
{
- do_error(dbh, TX_ERR_AUTOCOMMIT, "Turning on AutoCommit failed");
+ do_error(dbh, TX_ERR_AUTOCOMMIT, "Turning on AutoCommit failed", NULL);
return FALSE;
}
}
@@ -2126,7 +2098,7 @@
{
if (mysql_real_query(&imp_dbh->mysql, "SET AUTOCOMMIT=0", 16))
{
- do_error(dbh, TX_ERR_AUTOCOMMIT, "Turning off AutoCommit failed");
+ do_error(dbh, TX_ERR_AUTOCOMMIT, "Turning off AutoCommit failed", NULL);
return FALSE;
}
}
@@ -2142,12 +2114,7 @@
if (!SvTRUE(valuesv))
{
do_error(dbh, JW_ERR_NOT_IMPLEMENTED,
- "Transactions not supported by database"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ "Transactions not supported by database" ,NULL);
croak("Transactions not supported by database");
}
}
@@ -2806,8 +2773,32 @@
mysql_affected_rows(svsock));
}
- /* Store the result in the current statement handle */
- DBIc_NUM_FIELDS(imp_sth)= mysql_num_fields(imp_sth->result);
+ /* delete cached handle attributes */
+ /* XXX should be driven by a list to ease maintenance */
+ hv_delete((HV*)SvRV(sth), "NAME", 4, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "NULLABLE", 8, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "NUM_OF_FIELDS", 13, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "PRECISION", 9, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "SCALE", 5, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "TYPE", 4, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_insertid", 14, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_is_auto_increment", 23, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_is_blob", 13, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_is_key", 12, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_is_num", 12, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_is_pri_key", 16, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_length", 12, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_max_length", 16, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_table", 11, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_type", 10, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_type_name", 15, G_DISCARD);
+
+ /* Adjust NUM_OF_FIELDS - which also adjusts the row buffer size */
+ DBIc_NUM_FIELDS(imp_sth)= 0; /* for DBI <= 1.53 */
+ DBIS->set_attr_k(sth, sv_2mortal(newSVpvn("NUM_OF_FIELDS",13)), 0,
+ sv_2mortal(newSViv(mysql_num_fields(imp_sth->result)))
+ );
+
DBIc_ACTIVE_on(imp_sth);
if (dbis->debug >= 5)
@@ -2857,6 +2848,7 @@
char *table;
char *salloc;
int htype;
+ int errno;
my_ulonglong rows= 0;
/* thank you DBI.c for this info! */
@@ -2922,22 +2914,12 @@
if (!slen)
{
- do_error(h, JW_ERR_QUERY, "Missing table name"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(h, JW_ERR_QUERY, "Missing table name" ,NULL);
return -2;
}
if (!(table= malloc(slen+1)))
{
- do_error(h, JW_ERR_MEM, "Out of memory"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(h, JW_ERR_MEM, "Out of memory" ,NULL);
return -2;
}
@@ -2952,16 +2934,13 @@
*sbuf++= '\0';
*result= mysql_list_fields(svsock, table, NULL);
+
free(table);
if (!(*result))
{
do_error(h, mysql_errno(svsock), mysql_error(svsock)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
,mysql_sqlstate(svsock));
-#else
- );
-#endif
return -2;
}
@@ -2973,12 +2952,10 @@
(mysql_real_query(svsock, sbuf, slen))))
{
Safefree(salloc);
- do_error(h, mysql_errno(svsock), mysql_error(svsock)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,mysql_sqlstate(svsock));
-#else
- );
-#endif
+ do_error(h, mysql_errno(svsock), mysql_error(svsock),
+ mysql_sqlstate(svsock));
+ if (dbis->debug >= 2)
+ PerlIO_printf(DBILOGFP, "IGNORING ERROR errno %d\n", errno);
return -2;
}
Safefree(salloc);
@@ -2989,11 +2966,7 @@
if (mysql_errno(svsock))
do_error(h, mysql_errno(svsock), mysql_error(svsock)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
,mysql_sqlstate(svsock));
-#else
- );
-#endif
if (!*result)
rows= mysql_affected_rows(svsock);
@@ -4106,7 +4079,6 @@
if (DBIc_NUM_PARAMS(imp_sth))
{
unsigned int n;
- SV *sv;
char key[100];
I32 keylen;
for (n= 0; n < DBIc_NUM_PARAMS(imp_sth); n++)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/dbdimp.h new/DBD-mysql-4.002/dbdimp.h
--- old/DBD-mysql-4.001/dbdimp.h 2007-01-06 20:00:08.000000000 +0100
+++ new/DBD-mysql-4.002/dbdimp.h 2007-03-01 16:47:26.000000000 +0100
@@ -12,7 +12,7 @@
* You may distribute this under the terms of either the GNU General Public
* License or the Artistic License, as specified in the Perl README file.
*
- * $Id: dbdimp.h 8513 2007-01-05 01:07:31Z jimw $
+ * $Id: dbdimp.h 9183 2007-03-01 15:47:39Z capttofu $
*/
/*
@@ -36,6 +36,12 @@
#define NEW_DATATYPE_VERSION 50003
#define SSL_VERIFY_VERSION 50023
#define MYSQL_VERSION_5_0 50001
+/* This is to avoid the ugly #ifdef mess in dbdimp.c */
+#if MYSQL_VERSION_ID < SQL_STATE_VERSION
+#define mysql_sqlstate(svsock) (NULL)
+#endif
+
+
/*
* The following are return codes passed in $h->err in case of
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/lib/Bundle/DBD/mysql.pm new/DBD-mysql-4.002/lib/Bundle/DBD/mysql.pm
--- old/DBD-mysql-4.001/lib/Bundle/DBD/mysql.pm 2007-01-04 04:14:50.000000000 +0100
+++ new/DBD-mysql-4.002/lib/Bundle/DBD/mysql.pm 2007-01-15 03:39:33.000000000 +0100
@@ -2,7 +2,7 @@
package Bundle::DBD::mysql;
-$VERSION = 4.001;
+$VERSION = 4.002;
1;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/lib/DBD/mysql.pm new/DBD-mysql-4.002/lib/DBD/mysql.pm
--- old/DBD-mysql-4.001/lib/DBD/mysql.pm 2007-01-04 04:14:50.000000000 +0100
+++ new/DBD-mysql-4.002/lib/DBD/mysql.pm 2007-03-01 23:34:46.000000000 +0100
@@ -9,7 +9,7 @@
use Carp ();
@ISA = qw(DynaLoader);
-$VERSION = 4.001;
+$VERSION = '4.002';
bootstrap DBD::mysql $VERSION;
@@ -98,6 +98,7 @@
package DBD::mysql::dr; # ====== DRIVER ======
use strict;
use DBI qw(:sql_types);
+use DBI::Const::GetInfoType;
sub connect {
my($drh, $dsn, $username, $password, $attrhash) = @_;
@@ -252,38 +253,113 @@
die "_SelectDB is removed from this module; use DBI->connect instead.";
}
-{
- my $names = ['TABLE_CAT', 'TABLE_SCHEM', 'TABLE_NAME',
- 'TABLE_TYPE', 'REMARKS'];
-
- sub table_info ($) {
- my $dbh = shift;
- my $sth = $dbh->prepare("SHOW TABLES");
- return undef unless $sth;
- if (!$sth->execute()) {
- return DBI::set_err($dbh, $sth->err(), $sth->errstr());
- }
- my @tables;
+sub table_info ($) {
+ my ($dbh, $catalog, $schema, $table, $type, $attr) = @_;
+ my @names = qw(TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS);
+ my @rows;
+
+ my $sponge = DBI->connect("DBI:Sponge:", '','')
+ or return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr");
+
+ # Return the list of catalogs
+ if (defined $catalog && $catalog eq "%" &&
+ (!defined($schema) || $schema eq "") &&
+ (!defined($table) || $table eq ""))
+ {
+ @rows = (); # Empty, because MySQL doesn't support catalogs (yet)
+ }
+
+ # Return the list of schemas
+ elsif (defined $schema && $schema eq "%" &&
+ (!defined($catalog) || $catalog eq "") &&
+ (!defined($table) || $table eq ""))
+ {
+ my $sth = $dbh->prepare("SHOW DATABASES")
+ or return undef;
+
+ $sth->execute()
+ or return DBI::set_err($dbh, $sth->err(), $sth->errstr());
+
while (my $ref = $sth->fetchrow_arrayref()) {
- push(@tables, [ undef, undef, $ref->[0], 'TABLE', undef ]);
- }
- my $dbh2;
- if (!($dbh2 = $dbh->{'~dbd_driver~_sponge_dbh'})) {
- $dbh2 = $dbh->{'~dbd_driver~_sponge_dbh'} =
- DBI->connect("DBI:Sponge:");
- if (!$dbh2) {
- DBI::set_err($dbh, 1, $DBI::errstr);
- return undef;
+ push(@rows, [ undef, $ref->[0], undef, undef, undef ]);
+ }
+ }
+
+ # Return the list of table types
+ elsif (defined $type && $type eq "%" &&
+ (!defined($catalog) || $catalog eq "") &&
+ (!defined($schema) || $schema eq "") &&
+ (!defined($table) || $table eq ""))
+ {
+ @rows = (
+ [ undef, undef, undef, "TABLE", undef ],
+ [ undef, undef, undef, "VIEW", undef ],
+ );
+ }
+
+ # Special case: a catalog other than undef, "", or "%"
+ elsif (defined $catalog && $catalog ne "" && $catalog ne "%") {
+ @rows = (); # Nothing, because MySQL doesn't support catalogs yet.
+ }
+
+ # Uh oh, we actually have a meaty table_info call. Work is required!
+ else {
+ my @schemas;
+
+ # If no table was specified, we want them all
+ $table ||= "%";
+
+ # If something was given for the schema, we need to expand it to
+ # a list of schemas, since it may be a wildcard.
+ if (defined $schema && $schema ne "") {
+ my $sth = $dbh->prepare("SHOW DATABASES LIKE " .
+ $dbh->quote($schema))
+ or return undef;
+ $sth->execute()
+ or return DBI::set_err($dbh, $sth->err(), $sth->errstr());
+
+ while (my $ref = $sth->fetchrow_arrayref()) {
+ push @schemas, $ref->[0];
}
+ # Otherwise we want the current database
+ } else {
+ push @schemas, $dbh->selectrow_array("SELECT DATABASE()");
}
- my $sth2 = $dbh2->prepare("SHOW TABLES", { 'rows' => \@tables,
- 'NAME' => $names,
- 'NUM_OF_FIELDS' => 5 });
- if (!$sth2) {
- DBI::set_err($sth2, $dbh2->err(), $dbh2->errstr());
+
+ # Figure out which table types are desired
+ my ($want_tables, $want_views);
+ if (defined $type && $type ne "") {
+ $want_tables = ($type =~ m/table/i);
+ $want_views = ($type =~ m/view/i);
+ } else {
+ $want_tables = $want_views = 1;
+ }
+
+ foreach my $database (@schemas) {
+ my $sth = $dbh->prepare("SHOW /*!50002 FULL*/ TABLES FROM " .
+ $dbh->quote_identifier($database) .
+ " LIKE " . $dbh->quote($table))
+ or return undef;
+ $sth->execute() or
+ return DBI::set_err($dbh, $sth->err(), $sth->errstr());
+
+ while (my $ref = $sth->fetchrow_arrayref()) {
+ my $type = (defined $ref->[1] &&
+ $ref->[1] =~ /view/i) ? 'VIEW' : 'TABLE';
+ next if $type eq 'TABLE' && not $want_tables;
+ next if $type eq 'VIEW' && not $want_views;
+ push @rows, [ undef, $database, $ref->[0], $type, undef ];
+ }
}
- $sth2;
}
+
+ my $sth = $sponge->prepare("table_info", {
+ rows => \@rows,
+ NUM_OF_FIELDS => scalar @names,
+ NAME => \@names,
+ }) or return $dbh->DBI::set_err($sponge->err(), $sponge->errstr());
+
+ return $sth;
}
sub _ListTables {
@@ -297,8 +373,10 @@
sub column_info {
my ($dbh, $catalog, $schema, $table, $column) = @_;
- return $dbh->set_err(1, "column_info doesn't support column selection")
- if $column ne "%";
+ # ODBC allows a NULL to mean all columns, so we'll accept undef
+ $column = '%' unless defined $column;
+
+ my $ER_NO_SUCH_TABLE= 1146;
my $table_id = $dbh->quote_identifier($catalog, $schema, $table);
@@ -313,20 +391,36 @@
SCOPE_CAT SCOPE_SCHEM SCOPE_NAME MAX_CARDINALITY
DTD_IDENTIFIER IS_SELF_REF
mysql_is_pri_key mysql_type_name mysql_values
+ mysql_is_auto_increment
);
my %col_info;
local $dbh->{FetchHashKeyName} = 'NAME_lc';
- my $desc_sth = $dbh->prepare("DESCRIBE $table_id");
+ # only ignore ER_NO_SUCH_TABLE in internal_execute if issued from here
+ print "DESCRIBE $table_id " . $dbh->quote($column) . "\n";
+ my $desc_sth = $dbh->prepare("DESCRIBE $table_id " . $dbh->quote($column));
my $desc = $dbh->selectall_arrayref($desc_sth, { Columns=>{} });
- return $desc_sth if $desc_sth->err();
+ #return $desc_sth if $desc_sth->err();
+ if (my $err = $desc_sth->err())
+ {
+ # return the error, unless it is due to the table not
+ # existing per DBI spec
+ if ($err != $ER_NO_SUCH_TABLE)
+ {
+ return undef;
+ }
+ $dbh->set_err(undef,undef);
+ $desc = [];
+ }
my $ordinal_pos = 0;
foreach my $row (@$desc) {
my $type = $row->{type};
$type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/;
my $basetype = lc($1);
+ my $typemod = $2;
+ my $attr = $3;
my $info = $col_info{ $row->{field} } = {
TABLE_CAT => $catalog,
@@ -340,15 +434,17 @@
ORDINAL_POSITION => ++$ordinal_pos,
mysql_is_pri_key => ($row->{key} eq 'PRI'),
mysql_type_name => $row->{type},
+ mysql_is_auto_increment => ($row->{extra} =~ /auto_increment/i ? 1 :
+ 0),
};
# This code won't deal with a pathalogical case where a value
# contains a single quote followed by a comma, and doesn't unescape
# any escaped values. But who would use those in an enum or set?
- my @type_params = ($2 && index($2,"'")>=0)
- ? ("$2," =~ /'(.*?)',/g) # assume all are quoted
- : split /,/, $2||''; # no quotes, plain list
+ my @type_params = ($typemod && index($typemod,"'")>=0)
+ ? ("$typemod," =~ /'(.*?)',/g) # assume all are quoted
+ : split /,/, $typemod||''; # no quotes, plain list
s/''/'/g for @type_params; # undo doubling of quotes
- my @type_attr = split / /, $3||'';
+ my @type_attr = split / /, $attr||'';
#warn "$type: $basetype [@type_params] [@type_attr]\n";
$info->{DATA_TYPE} = SQL_VARCHAR();
@@ -473,6 +569,96 @@
}
+sub foreign_key_info {
+ my ($dbh,
+ $pk_catalog, $pk_schema, $pk_table,
+ $fk_catalog, $fk_schema, $fk_table,
+ ) = @_;
+
+ # INFORMATION_SCHEMA.KEY_COLUMN_USAGE was added in 5.0.6
+ my ($maj, $min, $point) = _version($dbh);
+ return if $maj < 5 || ($maj == 5 && $point < 6);
+
+ my $sql = <<'EOF';
+SELECT NULL AS PKTABLE_CAT,
+ A.REFERENCED_TABLE_SCHEMA AS PKTABLE_SCHEM,
+ A.REFERENCED_TABLE_NAME AS PKTABLE_NAME,
+ A.REFERENCED_COLUMN_NAME AS PKCOLUMN_NAME,
+ A.TABLE_CATALOG AS FKTABLE_CAT,
+ A.TABLE_SCHEMA AS FKTABLE_SCHEM,
+ A.TABLE_NAME AS FKTABLE_NAME,
+ A.COLUMN_NAME AS FKCOLUMN_NAME,
+ A.ORDINAL_POSITION AS KEY_SEQ,
+ NULL AS UPDATE_RULE,
+ NULL AS DELETE_RULE,
+ A.CONSTRAINT_NAME AS FK_NAME,
+ NULL AS PK_NAME,
+ NULL AS DEFERABILITY,
+ NULL AS UNIQUE_OR_PRIMARY
+ FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE A,
+ INFORMATION_SCHEMA.TABLE_CONSTRAINTS B
+ WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA AND A.TABLE_NAME = B.TABLE_NAME
+ AND A.CONSTRAINT_NAME = B.CONSTRAINT_NAME AND B.CONSTRAINT_TYPE IS NOT NULL
+EOF
+
+ my @where;
+ my @bind;
+
+ # catalogs are not yet supported by MySQL
+
+# if (defined $pk_catalog) {
+# push @where, 'A.REFERENCED_TABLE_CATALOG = ?';
+# push @bind, $pk_catalog;
+# }
+
+ if (defined $pk_schema) {
+ push @where, 'A.REFERENCED_TABLE_SCHEMA = ?';
+ push @bind, $pk_schema;
+ }
+
+ if (defined $pk_table) {
+ push @where, 'A.REFERENCED_TABLE_NAME = ?';
+ push @bind, $pk_table;
+ }
+
+# if (defined $fk_catalog) {
+# push @where, 'A.TABLE_CATALOG = ?';
+# push @bind, $fk_schema;
+# }
+
+ if (defined $fk_schema) {
+ push @where, 'A.TABLE_SCHEMA = ?';
+ push @bind, $fk_schema;
+ }
+
+ if (defined $fk_table) {
+ push @where, 'A.TABLE_NAME = ?';
+ push @bind, $fk_table;
+ }
+
+ if (@where) {
+ $sql .= ' AND ';
+ $sql .= join ' AND ', @where;
+ }
+ $sql .= " ORDER BY A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION";
+
+ local $dbh->{FetchHashKeyName} = 'NAME_uc';
+ my $sth = $dbh->prepare($sql);
+ $sth->execute(@bind);
+
+ return $sth;
+}
+
+
+sub _version {
+ my $dbh = shift;
+
+ return
+ $dbh->get_info($DBI::Const::GetInfoType::GetInfoType{SQL_DBMS_VER})
+ =~ /(\d+)\.(\d+)\.(\d+)/;
+}
+
+
####################
# get_info()
# Generated by DBI::DBD::Metadata
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/MANIFEST new/DBD-mysql-4.002/MANIFEST
--- old/DBD-mysql-4.001/MANIFEST 2006-12-23 18:54:54.000000000 +0100
+++ new/DBD-mysql-4.002/MANIFEST 2007-03-01 16:54:44.000000000 +0100
@@ -8,6 +8,7 @@
t/40bindparam2.t
t/41bindparam.t
t/42bindparam.t
+t/40catalog.t
t/40blobs.t
t/40listfields.t
t/40nulls.t
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/META.yml new/DBD-mysql-4.002/META.yml
--- old/DBD-mysql-4.001/META.yml 2007-01-08 02:07:47.000000000 +0100
+++ new/DBD-mysql-4.002/META.yml 2007-03-02 04:29:26.000000000 +0100
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: DBD-mysql
-version: 4.001
+version: 4.002
version_from: lib/DBD/mysql.pm
installdirs: site
requires:
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/mysql.xs new/DBD-mysql-4.002/mysql.xs
--- old/DBD-mysql-4.001/mysql.xs 2007-01-08 01:39:05.000000000 +0100
+++ new/DBD-mysql-4.002/mysql.xs 2007-03-01 16:47:26.000000000 +0100
@@ -1,6 +1,6 @@
/* Hej, Emacs, this is -*- C -*- mode!
- $Id: mysql.xs 8519 2007-01-06 23:39:24Z jimw $
+ $Id: mysql.xs 9183 2007-03-01 15:47:39Z capttofu $
Copyright (c) 2003 Rudolf Lippan
Copyright (c) 1997-2003 Jochen Wiedmann
@@ -54,12 +54,7 @@
MYSQL_RES* res = mysql_list_dbs(sock, NULL);
if (!res)
{
- do_error(drh, mysql_errno(sock), mysql_error(sock)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- , mysql_sqlstate(sock));
-#else
- );
-#endif
+ do_error(drh, mysql_errno(sock), mysql_error(sock), mysql_sqlstate(sock));
}
else
{
@@ -103,12 +98,8 @@
sock = mysql_dr_connect(drh, &mysql, NULL, host, port, user, password, NULL, NULL);
if (sock == NULL)
{
- do_error(drh, mysql_errno(&mysql), mysql_error(&mysql)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- , mysql_sqlstate(&mysql));
-#else
- );
-#endif
+ do_error(drh, mysql_errno(&mysql), mysql_error(&mysql),
+ mysql_sqlstate(&mysql));
XSRETURN_NO;
}
}
@@ -129,12 +120,7 @@
char* buffer = malloc(strlen(dbname)+50);
if (buffer == NULL)
{
- do_error(drh, JW_ERR_MEM, "Out of memory"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(drh, JW_ERR_MEM, "Out of memory" ,NULL);
XSRETURN_NO;
}
else
@@ -154,12 +140,7 @@
char* buffer = malloc(strlen(dbname)+50);
if (buffer == NULL)
{
- do_error(drh, JW_ERR_MEM, "Out of memory"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(drh, JW_ERR_MEM, "Out of memory" ,NULL);
XSRETURN_NO;
}
else
@@ -178,12 +159,7 @@
if (retval)
{
do_error(SvOK(dbh) ? dbh : drh, mysql_errno(sock),
- mysql_error(sock)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,mysql_sqlstate(sock));
-#else
- );
-#endif
+ mysql_error(sock) ,mysql_sqlstate(sock));
}
if (SvOK(dbh))
@@ -232,12 +208,7 @@
!(res = mysql_list_dbs(&imp_dbh->mysql, NULL))))
{
do_error(dbh, mysql_errno(&imp_dbh->mysql),
- mysql_error(&imp_dbh->mysql)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,mysql_sqlstate(&imp_dbh->mysql));
-#else
- );
-#endif
+ mysql_error(&imp_dbh->mysql), mysql_sqlstate(&imp_dbh->mysql));
}
else
{
@@ -300,6 +271,8 @@
"mysql.xs do() use_server_side_prepare %d\n",
use_server_side_prepare);
+ hv_store((HV*)SvRV(dbh), "Statement", 9, SvREFCNT_inc(statement), 0);
+
if (use_server_side_prepare)
{
str_ptr= SvPV(statement, slen);
@@ -317,11 +290,7 @@
else
{
do_error(dbh, mysql_stmt_errno(stmt), mysql_stmt_error(stmt)
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
,mysql_stmt_sqlstate(stmt));
-#else
- );
-#endif
retval=-2;
}
mysql_stmt_close(stmt);
@@ -613,23 +582,13 @@
else
{
RETVAL = 0;
- do_error(sth, JW_ERR_NOT_ACTIVE, "Statement not active"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(sth, JW_ERR_NOT_ACTIVE, "Statement not active" ,NULL);
}
}
else
{
RETVAL = 0;
- do_error(sth, JW_ERR_NOT_ACTIVE, "No result set"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(sth, JW_ERR_NOT_ACTIVE, "No result set" ,NULL);
}
}
else
@@ -640,12 +599,7 @@
RETVAL = 1;
} else {
RETVAL = 0;
- do_error(sth, JW_ERR_NOT_ACTIVE, "Statement not active"
-#if MYSQL_VERSION_ID >= SQL_STATE_VERSION
- ,NULL);
-#else
- );
-#endif
+ do_error(sth, JW_ERR_NOT_ACTIVE, "Statement not active" ,NULL);
}
#if (MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION)
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/t/20createdrop.t new/DBD-mysql-4.002/t/20createdrop.t
--- old/DBD-mysql-4.001/t/20createdrop.t 2006-12-23 19:03:30.000000000 +0100
+++ new/DBD-mysql-4.002/t/20createdrop.t 2007-03-01 16:47:26.000000000 +0100
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
#
-# $Id: 20createdrop.t 8435 2006-12-23 19:03:49Z capttofu $
+# $Id: 20createdrop.t 9183 2007-03-01 15:47:39Z capttofu $
#
# This is a skeleton test. For writing new tests, take this file
# and modify/extend it.
@@ -73,6 +73,12 @@
or DbiError($dbh->err, $dbh->errstr);
#
+ # ... check do() sets $dbh->{Statement}
+ #
+ Test($state or $dbh->{Statement} eq "DROP TABLE $table")
+ or DbiError(1, "do() didn't set Statement attribute");
+
+ #
# Finally disconnect.
#
Test($state or $dbh->disconnect())
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/t/40catalog.t new/DBD-mysql-4.002/t/40catalog.t
--- old/DBD-mysql-4.001/t/40catalog.t 1970-01-01 01:00:00.000000000 +0100
+++ new/DBD-mysql-4.002/t/40catalog.t 2007-03-02 04:25:49.000000000 +0100
@@ -0,0 +1,284 @@
+#!perl -w
+# vim: ft=perl
+
+use Data::Dumper;
+use Test::More;
+use DBI;
+use strict;
+$|= 1;
+
+my $mdriver= "";
+
+our ($test_dsn, $test_user, $test_password);
+foreach my $file ("lib.pl", "t/lib.pl") {
+ do $file;
+ if ($@) {
+ print STDERR "Error while executing $file: $@\n";
+ exit 10;
+ }
+ last if $mdriver ne '';
+}
+
+my $dbh= DBI->connect($test_dsn, $test_user, $test_password,
+ { RaiseError => 1, PrintError => 1, AutoCommit => 0 });
+
+plan tests => 75;
+
+ok(defined $dbh, "connecting");
+
+my $sth;
+
+my ($version)= $dbh->selectrow_array("SELECT version()")
+ or DbiError($dbh->err, $dbh->errstr);
+
+#
+# Bug #26604: foreign_key_info() implementation
+#
+# The tests for this are adapted from the Connector/J test suite.
+#
+SKIP: {
+ skip "Server is too old to support INFORMATION_SCHEMA for foreign keys", 16
+ if substr($version, 0, 1) < 5;
+
+ my ($dummy,$have_innodb)=
+ $dbh->selectrow_array("SHOW VARIABLES LIKE 'have_innodb'")
+ or DbiError($dbh->err, $dbh->errstr);
+ skip "Server doesn't support InnoDB, needed for testing foreign keys", 16
+ unless defined $have_innodb && $have_innodb eq "YES";
+
+ ok($dbh->do(qq{DROP TABLE IF EXISTS child, parent}), "cleaning up");
+
+ ok($dbh->do(qq{CREATE TABLE parent(id INT NOT NULL,
+ PRIMARY KEY (id)) ENGINE=INNODB}));
+ ok($dbh->do(qq{CREATE TABLE child(id INT, parent_id INT,
+ FOREIGN KEY (parent_id)
+ REFERENCES parent(id) ON DELETE SET NULL)
+ ENGINE=INNODB}));
+
+ $sth= $dbh->foreign_key_info(undef, undef, "parent", undef, undef, "child");
+ my ($info)= $sth->fetchall_arrayref({});
+
+ is($info->[0]->{PKTABLE_NAME}, "parent");
+ is($info->[0]->{PKCOLUMN_NAME}, "id");
+ is($info->[0]->{FKTABLE_NAME}, "child");
+ is($info->[0]->{FKCOLUMN_NAME}, "parent_id");
+
+ $sth= $dbh->foreign_key_info(undef, undef, "parent", undef, undef, undef);
+ ($info)= $sth->fetchall_arrayref({});
+
+ is($info->[0]->{PKTABLE_NAME}, "parent");
+ is($info->[0]->{PKCOLUMN_NAME}, "id");
+ is($info->[0]->{FKTABLE_NAME}, "child");
+ is($info->[0]->{FKCOLUMN_NAME}, "parent_id");
+
+ $sth= $dbh->foreign_key_info(undef, undef, undef, undef, undef, "child");
+ ($info)= $sth->fetchall_arrayref({});
+
+ is($info->[0]->{PKTABLE_NAME}, "parent");
+ is($info->[0]->{PKCOLUMN_NAME}, "id");
+ is($info->[0]->{FKTABLE_NAME}, "child");
+ is($info->[0]->{FKCOLUMN_NAME}, "parent_id");
+
+ ok($dbh->do(qq{DROP TABLE IF EXISTS child, parent}), "cleaning up");
+};
+
+#
+# table_info() tests
+#
+# These tests assume that no other tables name like 't_dbd_mysql_%' exist on
+# the server we are using for testing.
+#
+SKIP: {
+ my $sth = $dbh->table_info("%", undef, undef, undef);
+ is(scalar @{$sth->fetchall_arrayref()}, 0, "No catalogs expected");
+
+ $sth = $dbh->table_info(undef, "%", undef, undef);
+ ok(scalar @{$sth->fetchall_arrayref()} > 0, "Some schemas expected");
+
+ $sth = $dbh->table_info(undef, undef, undef, "%");
+ ok(scalar @{$sth->fetchall_arrayref()} > 0, "Some table types expected");
+
+ ok($dbh->do(qq{DROP TABLE IF EXISTS t_dbd_mysql_t1, t_dbd_mysql_t11,
+ t_dbd_mysql_t2, t_dbd_mysqlat2,
+ `t_dbd_mysql_a'b`,
+ `t_dbd_mysql_a``b`}),
+ "cleaning up");
+ ok($dbh->do(qq{CREATE TABLE t_dbd_mysql_t1 (a INT)}) and
+ $dbh->do(qq{CREATE TABLE t_dbd_mysql_t11 (a INT)}) and
+ $dbh->do(qq{CREATE TABLE t_dbd_mysql_t2 (a INT)}) and
+ $dbh->do(qq{CREATE TABLE t_dbd_mysqlat2 (a INT)}) and
+ $dbh->do(qq{CREATE TABLE `t_dbd_mysql_a'b` (a INT)}) and
+ $dbh->do(qq{CREATE TABLE `t_dbd_mysql_a``b` (a INT)}),
+ "creating test tables");
+
+ # $base is our base table name, with the _ escaped to avoid extra matches
+ my $esc = $dbh->get_info(14); # SQL_SEARCH_PATTERN_ESCAPE
+ (my $base = "t_dbd_mysql_") =~ s/([_%])/$esc$1/g;
+
+ # Test fetching info on a single table
+ $sth = $dbh->table_info(undef, undef, $base . "t1", undef);
+ my $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_CAT}, undef);
+ is($info->[0]->{TABLE_NAME}, "t_dbd_mysql_t1");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is(scalar @$info, 1, "one row expected");
+
+ # Test fetching info on a wildcard
+ $sth = $dbh->table_info(undef, undef, $base . "t1%", undef);
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_CAT}, undef);
+ is($info->[0]->{TABLE_NAME}, "t_dbd_mysql_t1");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is($info->[1]->{TABLE_CAT}, undef);
+ is($info->[1]->{TABLE_NAME}, "t_dbd_mysql_t11");
+ is($info->[1]->{TABLE_TYPE}, "TABLE");
+ is(scalar @$info, 2, "two rows expected");
+
+ # Test fetching info on a single table with escaped wildcards
+ $sth = $dbh->table_info(undef, undef, $base . "t2", undef);
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_CAT}, undef);
+ is($info->[0]->{TABLE_NAME}, "t_dbd_mysql_t2");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is(scalar @$info, 1, "only one table expected");
+
+ # Test fetching info on a single table with ` in name
+ $sth = $dbh->table_info(undef, undef, $base . "a`b", undef);
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_CAT}, undef);
+ is($info->[0]->{TABLE_NAME}, "t_dbd_mysql_a`b");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is(scalar @$info, 1, "only one table expected");
+
+ # Test fetching info on a single table with ' in name
+ $sth = $dbh->table_info(undef, undef, $base . "a'b", undef);
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_CAT}, undef);
+ is($info->[0]->{TABLE_NAME}, "t_dbd_mysql_a'b");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is(scalar @$info, 1, "only one table expected");
+
+ # Test fetching our tables with a wildcard schema
+ # NOTE: the performance of this could be bad if the mysql user we
+ # are connecting as can see lots of databases.
+ $sth = $dbh->table_info(undef, "%", $base . "%", undef);
+ $info = $sth->fetchall_arrayref({});
+
+ is(scalar @$info, 5, "five tables expected");
+
+ # Check that tables() finds and escapes the tables named with quotes
+ $info = [ $dbh->tables(undef, undef, $base . 'a%') ];
+ like($info->[0], qr/\.`t_dbd_mysql_a'b`$/, "table with single quote");
+ like($info->[1], qr/\.`t_dbd_mysql_a``b`$/, "table with back quote");
+ is(scalar @$info, 2, "two tables expected");
+
+ # Clean up
+ ok($dbh->do(qq{DROP TABLE IF EXISTS t_dbd_mysql_t1, t_dbd_mysql_t11,
+ t_dbd_mysql_t2, t_dbd_mysqlat2,
+ `t_dbd_mysql_a'b`,
+ `t_dbd_mysql_a``b`}),
+ "cleaning up");
+};
+
+#
+# view-related table_info tests
+#
+SKIP: {
+ skip "Server is too old to support views", 19
+ if substr($version, 0, 1) < 5;
+
+ #
+ # Bug #26603: (one part) support views in table_info()
+ #
+ ok($dbh->do(qq{DROP VIEW IF EXISTS bug26603_v1}) and
+ $dbh->do(qq{DROP TABLE IF EXISTS bug26603_t1}), "cleaning up");
+
+ ok($dbh->do(qq{CREATE TABLE bug26603_t1 (a INT)}) and
+ $dbh->do(qq{CREATE VIEW bug26603_v1 AS SELECT * FROM bug26603_t1}),
+ "creating resources");
+
+ # Try without any table type specified
+ $sth = $dbh->table_info(undef, undef, "bug26603%");
+ my $info = $sth->fetchall_arrayref({});
+ is($info->[1]->{TABLE_NAME}, "bug26603_v1");
+ is($info->[1]->{TABLE_TYPE}, "VIEW");
+ is(scalar @$info, 2, "two rows expected");
+
+ # Just get the view
+ $sth = $dbh->table_info(undef, undef, "bug26603%", "VIEW");
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_NAME}, "bug26603_v1");
+ is($info->[0]->{TABLE_TYPE}, "VIEW");
+ is(scalar @$info, 1, "one row expected");
+
+ # Just get the table
+ $sth = $dbh->table_info(undef, undef, "bug26603%", "TABLE");
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_NAME}, "bug26603_t1");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is(scalar @$info, 1, "one row expected");
+
+ # Get both tables and views
+ $sth = $dbh->table_info(undef, undef, "bug26603%", "'TABLE','VIEW'");
+ $info = $sth->fetchall_arrayref({});
+
+ is($info->[0]->{TABLE_NAME}, "bug26603_t1");
+ is($info->[0]->{TABLE_TYPE}, "TABLE");
+ is($info->[1]->{TABLE_NAME}, "bug26603_v1");
+ is($info->[1]->{TABLE_TYPE}, "VIEW");
+ is(scalar @$info, 2, "two rows expected");
+
+ ok($dbh->do(qq{DROP VIEW IF EXISTS bug26603_v1}) and
+ $dbh->do(qq{DROP TABLE IF EXISTS bug26603_t1}), "cleaning up");
+
+};
+
+#
+# column_info() tests
+#
+SKIP: {
+ ok($dbh->do(qq{DROP TABLE IF EXISTS t1}), "cleaning up");
+ ok($dbh->do(qq{CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT,
+ b INT,
+ `a_` INT,
+ `a'b` INT,
+ bar INT
+ )}), "creating table");
+
+ #
+ # Bug #26603: (one part) add mysql_is_autoincrement
+ #
+ $sth= $dbh->column_info(undef, undef, "t1", 'a');
+ my ($info)= $sth->fetchall_arrayref({});
+ is($info->[0]->{mysql_is_auto_increment}, 1);
+
+ $sth= $dbh->column_info(undef, undef, "t1", 'b');
+ ($info)= $sth->fetchall_arrayref({});
+ is($info->[0]->{mysql_is_auto_increment}, 0);
+
+ #
+ # Test that wildcards and odd names are handled correctly
+ #
+ $sth= $dbh->column_info(undef, undef, "t1", "a%");
+ ($info)= $sth->fetchall_arrayref({});
+ is(scalar @$info, 3);
+ $sth= $dbh->column_info(undef, undef, "t1", "a" . $dbh->get_info(14) . "_");
+ ($info)= $sth->fetchall_arrayref({});
+ is(scalar @$info, 1);
+ $sth= $dbh->column_info(undef, undef, "t1", "a'b");
+ ($info)= $sth->fetchall_arrayref({});
+ is(scalar @$info, 1);
+
+ ok($dbh->do(qq{DROP TABLE IF EXISTS t1}), "cleaning up");
+ $dbh->disconnect();
+};
+
+
+$dbh->disconnect();
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/t/40listfields.t new/DBD-mysql-4.002/t/40listfields.t
--- old/DBD-mysql-4.001/t/40listfields.t 2007-01-04 04:14:50.000000000 +0100
+++ new/DBD-mysql-4.002/t/40listfields.t 2007-03-01 16:47:26.000000000 +0100
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
#
-# $Id: 40listfields.t 8487 2006-12-28 23:35:52Z jimw $
+# $Id: 40listfields.t 9183 2007-03-01 15:47:39Z capttofu $
#
# This is a test for statement attributes being present appropriately.
#
@@ -75,14 +75,13 @@
Test($state or $dbh->column_info(undef,undef,$table,'%'));
#
- # Bug #23974: column_info does not return error when table does not exist
+ # Bug #23974: "column_info does not return error when table does not exist"
+ # DBI spec specifies that empty ref should be returned, not error
#
- {
- local $dbh->{PrintError}= 0;
- Test($state or
- ($sth= $dbh->column_info(undef,undef,"this_does_not_exist",'%')));
- Test($sth and $sth->err());
- }
+ Test($state or
+ ($sth= $dbh->column_info(undef,undef,"this_does_not_exist",'%')));
+
+ Test($sth and ! $sth->err());
Test($state or $sth = $dbh->prepare("SELECT * FROM $table"))
or DbiError($dbh->err, $dbh->errstr);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/t/80procs.t new/DBD-mysql-4.002/t/80procs.t
--- old/DBD-mysql-4.001/t/80procs.t 2006-12-24 14:35:46.000000000 +0100
+++ new/DBD-mysql-4.002/t/80procs.t 2007-02-24 16:39:26.000000000 +0100
@@ -113,6 +113,8 @@
Test($state or $sth->execute()) or
DbiError($dbh->err, $dbh->errstr);
+ $sth->finish;
+
my $proc_select = 'SELECT @a';
Test($state or $sth = $dbh->prepare($proc_select)) or
DbiError($dbh->err, $dbh->errstr);
@@ -120,6 +122,8 @@
Test($state or $sth->execute()) or
DbiError($dbh->err, $dbh->errstr);
+ $sth->finish;
+
Test($state or ($sth=$dbh->prepare("DROP PROCEDURE testproc"))) or
DbiError($dbh->err, $dbh->errstr);
@@ -148,6 +152,9 @@
my $dataset;
+ Test($state or ($sth->{NUM_OF_FIELDS} == 1)) or
+ DbiError($dbh->err, $dbh->errstr);
+
Test($state or $dataset = $sth->fetchrow_arrayref()) or
DbiError($dbh->err, $dbh->errstr);
@@ -159,6 +166,9 @@
Test($state or $more_results = $sth->more_results()) or
DbiError($dbh->err, $dbh->errstr);
+ Test($state or ($sth->{NUM_OF_FIELDS} == 2)) or
+ DbiError($dbh->err, $dbh->errstr);
+
Test($state or $dataset = $sth->fetchrow_arrayref()) or
DbiError($dbh->err, $dbh->errstr);
@@ -168,6 +178,9 @@
Test($state or $more_results = $sth->more_results()) or
DbiError($dbh->err, $dbh->errstr);
+ Test($state or ($sth->{NUM_OF_FIELDS} == 3)) or
+ DbiError($dbh->err, $dbh->errstr);
+
Test($state or $dataset = $sth->fetchrow_arrayref()) or
DbiError($dbh->err, $dbh->errstr);
@@ -177,7 +190,7 @@
Test($state or !($more_results = $sth->more_results())) or
DbiError($dbh->err, $dbh->errstr);
- $SIG{__WARN__} = sub { die @_ };
+ local $SIG{__WARN__} = sub { die @_ };
Test($state or $dbh->disconnect()) or
DbiError($dbh->err, $dbh->errstr);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/t/insertid.t new/DBD-mysql-4.002/t/insertid.t
--- old/DBD-mysql-4.001/t/insertid.t 2006-12-23 18:54:54.000000000 +0100
+++ new/DBD-mysql-4.002/t/insertid.t 2007-02-24 16:59:32.000000000 +0100
@@ -7,7 +7,8 @@
require "t/lib.pl";
while (Testing()) {
- my $dbh;
+ my ($dbh, $sth, $sth2);
+ my $max_id;
#
# Connect to the database
Test($state or
@@ -43,12 +44,18 @@
#
# Insert another row
#
- my $sth;
Test($state or ($sth = $dbh->prepare($q)));
Test($state or $sth->execute());
- Test($state or $sth->{'mysql_insertid'} eq 2);
- Test($state or $dbh->{'mysql_insertid'} eq 2);
+ Test($state or ($sth2= $dbh->prepare("SELECT max(id) FROM $table")));
+ Test($state or $sth2->execute());
+ Test($state or ($max_id= $sth2->fetch()));
+ # IMPORTANT: this will fail if you are using replication with
+ # an offset and auto_increment_increment, where your
+ # auto_increment values are stepped (ex: 1, 11, 21, ...)
+ Test($state or $sth->{'mysql_insertid'} == $max_id->[0]);
+ Test($state or $dbh->{'mysql_insertid'} == $max_id->[0]);
Test($state or $sth->finish());
+ Test($state or $sth2->finish());
#
# Drop the table
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/DBD-mysql-4.001/t/lib.pl new/DBD-mysql-4.002/t/lib.pl
--- old/DBD-mysql-4.001/t/lib.pl 2006-12-23 19:03:30.000000000 +0100
+++ new/DBD-mysql-4.002/t/lib.pl 2007-03-01 16:47:26.000000000 +0100
@@ -1,6 +1,6 @@
# Hej, Emacs, give us -*- perl mode here!
#
-# $Id: lib.pl 8435 2006-12-23 19:03:49Z capttofu $
+# $Id: lib.pl 9183 2007-03-01 15:47:39Z capttofu $
#
# lib.pl is the file where database specific things should live,
# whereever possible. For example, you define certain constants
@@ -11,6 +11,7 @@
use strict;
use vars qw($mdriver $dbdriver $childPid $test_dsn $test_user $test_password);
+$| = 1; # flush stdout asap to keep in sync with stderr
#
# Driver names; EDIT THIS!
@@ -166,7 +167,8 @@
print "ok $::numTests\n";
return 1;
} else {
- printf("not ok $::numTests%s\n",
+ my ($pack, $file, $line) = caller();
+ printf("not ok $::numTests%s at line $line\n",
(defined($error) ? " $error" : ""));
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org