Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix primary_key_info result ordering #39

Merged
merged 1 commit into from

2 participants

@ilmari

DBI documentation says

The statement handle will return one row per column, ordered by
TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and KEY_SEQ.

But since we're only querying one table the three first ones are by
definition the same, so it's only necessary to sort by KEY_SEQ.

This happened to come out in the same order on previous versions of
perl, but as of 5.17.10, hash insertion and traversal order is more
randomised, so now it fails mos of the time.

@ilmari ilmari Fix primary_key_info result ordering
DBI documentation says

> The statement handle will return one row per column, ordered by
> TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and KEY_SEQ.

But since we're only querying one table the three first ones are by
definition the same, so it's only necessary to sort by KEY_SEQ.

This happened to come out in the same order on previous versions of
perl, but as of 5.17.10, hash insertion and traversal order is more
randomised, so now it fails mos of the time.
2ff0f35
@CaptTofu CaptTofu merged commit b6038db into CaptTofu:master
@jperkin jperkin referenced this pull request from a commit in joyent/pkgsrc
ryoon Update to 4.023
Changelog:
2013-04-12 Patrick Galbraith et open source community <patg at patg dot net> (4.023)
* Fix primary_key_info result ordering - CaptTofu/DBD-mysql#39 - Dagfinn Ilmari Mannsåker
* allow compilation with msvc - CaptTofu/DBD-mysql#37 - Walde Christian
* just to set MYSQL_OPT_WRITE_TIMEOUT and MYSQL_OPT_READ_TIMEOUT by dsn - CaptTofu/DBD-mysql#36 - Naosuke Yokoe
* just remove unnecessary "my" - CaptTofu/DBD-mysql#34 - Shoichi Kaji
* eval $ExtUtils::MakeMaker::VERSION requires for old ExtUtils::MakeMaker - CaptTofu/DBD-mysql#32 - Daisuke Murase
* Updated documentation to reflect that bugs will be reported at rt.cpan.org
* Updated version
* Chased tail finding issue with -1 being converted to max unsigned int in PS mode
20ede7e
@jperkin jperkin referenced this pull request from a commit in joyent/pkgsrc
ryoon Update to 4.023
Changelog:
2013-04-12 Patrick Galbraith et open source community <patg at patg dot net> (4.023)
* Fix primary_key_info result ordering - CaptTofu/DBD-mysql#39 - Dagfinn Ilmari Mannsåker
* allow compilation with msvc - CaptTofu/DBD-mysql#37 - Walde Christian
* just to set MYSQL_OPT_WRITE_TIMEOUT and MYSQL_OPT_READ_TIMEOUT by dsn - CaptTofu/DBD-mysql#36 - Naosuke Yokoe
* just remove unnecessary "my" - CaptTofu/DBD-mysql#34 - Shoichi Kaji
* eval $ExtUtils::MakeMaker::VERSION requires for old ExtUtils::MakeMaker - CaptTofu/DBD-mysql#32 - Daisuke Murase
* Updated documentation to reflect that bugs will be reported at rt.cpan.org
* Updated version
* Chased tail finding issue with -1 being converted to max unsigned int in PS mode
eb392c6
@jsonn jsonn referenced this pull request from a commit in jsonn/pkgsrc
ryoon Update to 4.023
Changelog:
2013-04-12 Patrick Galbraith et open source community <patg at patg dot net> (4.023)
* Fix primary_key_info result ordering - CaptTofu/DBD-mysql#39 - Dagfinn Ilmari Mannsåker
* allow compilation with msvc - CaptTofu/DBD-mysql#37 - Walde Christian
* just to set MYSQL_OPT_WRITE_TIMEOUT and MYSQL_OPT_READ_TIMEOUT by dsn - CaptTofu/DBD-mysql#36 - Naosuke Yokoe
* just remove unnecessary "my" - CaptTofu/DBD-mysql#34 - Shoichi Kaji
* eval $ExtUtils::MakeMaker::VERSION requires for old ExtUtils::MakeMaker - CaptTofu/DBD-mysql#32 - Daisuke Murase
* Updated documentation to reflect that bugs will be reported at rt.cpan.org
* Updated version
* Chased tail finding issue with -1 being converted to max unsigned int in PS mode
aea51ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2013
  1. @ilmari

    Fix primary_key_info result ordering

    ilmari authored
    DBI documentation says
    
    > The statement handle will return one row per column, ordered by
    > TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and KEY_SEQ.
    
    But since we're only querying one table the three first ones are by
    definition the same, so it's only necessary to sort by KEY_SEQ.
    
    This happened to come out in the same order on previous versions of
    perl, but as of 5.17.10, hash insertion and traversal order is more
    randomised, so now it fails mos of the time.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/DBD/mysql.pm
View
6 lib/DBD/mysql.pm
@@ -634,7 +634,11 @@ sub primary_key_info {
return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr"));
my $sth= $sponge->prepare("primary_key_info $table", {
- rows => [ map { [ @{$_}{@names} ] } values %col_info ],
+ rows => [
+ map { [ @{$_}{@names} ] }
+ sort { $a->{KEY_SEQ} <=> $b->{KEY_SEQ} }
+ values %col_info
+ ],
NUM_OF_FIELDS => scalar @names,
NAME => \@names,
}) or
Something went wrong with that request. Please try again.