#!/usr/bin/perl use strict; use warnings; use DBI qw(:sql_types); my $dsn = 'dbi:mysql:database=test'; my $dbh = DBI->connect( $dsn, 'root', undef, { AutoCommit => 1, PrintError => 0, RaiseError => 1 } ); $dbh->do("DROP TABLE IF EXISTS bug26786"); $dbh->do("CREATE TABLE bug26786 (user_id integer primary key, group_id integer, index(group_id))"); my $sth = $dbh->primary_key_info( undef, 'test', 'bug26786' ); my $rows = $sth->fetchall_arrayref({}); while(my $row = (shift(@$rows))) { print "PK_NAME - $row->{PK_NAME}", "\t"; print "TABLE_NAME - $row->{TABLE_NAME}", "\t"; print "COLUMN_NAME - $row->{COLUMN_NAME}", "\n"; } $dbh->disconnect();