Skip to content
This repository

Fix primary_key_info result ordering #39

Merged
merged 1 commit into from about 1 year ago

2 participants

Dagfinn Ilmari Mannsåker Patrick Galbraith
Dagfinn Ilmari Mannsåker

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.

Dagfinn Ilmari Mannsåker 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
Patrick Galbraith CaptTofu merged commit b6038db into from April 12, 2013
Patrick Galbraith CaptTofu closed this April 12, 2013
Jonathan Perkin jperkin referenced this pull request from a commit in joyent/pkgsrc April 21, 2013
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
Jonathan Perkin jperkin referenced this pull request from a commit in joyent/pkgsrc April 21, 2013
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 24, 2013
Dagfinn Ilmari Mannsåker 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  lib/DBD/mysql.pm
6  lib/DBD/mysql.pm
@@ -634,7 +634,11 @@ sub primary_key_info {
634 634
       return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr"));
635 635
 
636 636
   my $sth= $sponge->prepare("primary_key_info $table", {
637  
-      rows          => [ map { [ @{$_}{@names} ] } values %col_info ],
  637
+      rows          => [
  638
+        map { [ @{$_}{@names} ] }
  639
+        sort { $a->{KEY_SEQ} <=> $b->{KEY_SEQ} }
  640
+        values %col_info
  641
+      ],
638 642
       NUM_OF_FIELDS => scalar @names,
639 643
       NAME          => \@names,
640 644
       }) or
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.