svn commit: r362767 - in head/databases/p5-DBIx-SearchBuilder: . files
Dmitry Sivachenko
demon at FreeBSD.org
Thu Jul 24 06:01:59 UTC 2014
Author: demon
Date: Thu Jul 24 06:01:58 2014
New Revision: 362767
URL: http://svnweb.freebsd.org/changeset/ports/362767
QAT: https://qat.redports.org/buildarchive/r362767/
Log:
Add a patch from upstream (1.65_1) to speedup some PostgreSQL queries.
(I applied version from upstream)
PR: 191734
Submitted by: Michelle Sullivan <michelle at sorbs.net>
Added:
head/databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1 (contents, props changed)
Modified:
head/databases/p5-DBIx-SearchBuilder/Makefile
Modified: head/databases/p5-DBIx-SearchBuilder/Makefile
==============================================================================
--- head/databases/p5-DBIx-SearchBuilder/Makefile Thu Jul 24 05:54:50 2014 (r362766)
+++ head/databases/p5-DBIx-SearchBuilder/Makefile Thu Jul 24 06:01:58 2014 (r362767)
@@ -3,6 +3,7 @@
PORTNAME= DBIx-SearchBuilder
PORTVERSION= 1.65
+PORTREVISION= 1
CATEGORIES= databases perl5
MASTER_SITES= CPAN
PKGNAMEPREFIX= p5-
Added: head/databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1 Thu Jul 24 06:01:58 2014 (r362767)
@@ -0,0 +1,46 @@
+--- lib/DBIx/SearchBuilder/Handle/Pg.pm 2013-07-02 21:12:09.000000000 +0400
++++ lib/DBIx/SearchBuilder/Handle/Pg.pm 2014-07-08 23:11:22.000000000 +0400
+@@ -235,9 +235,15 @@ sub DistinctQuery {
+ # It's hard to show with tests. Pg's optimizer can choose execution
+ # plan not guaranting order
+
+- # So if we are ordering by something that is not in 'main', the we GROUP
+- # BY all columns and adjust the ORDER_BY accordingly
+- local $sb->{group_by} = [ map {+{FIELD => $_}} $self->Fields($table) ];
++ my $groups;
++ if ($self->DatabaseVersion =~ /^(\d+)\.(\d+)/ and ($1 > 9 or ($1 == 9 and $2 >= 1))) {
++ # Pg 9.1 supports "SELECT main.foo ... GROUP BY main.id" if id is the primary key
++ $groups = [ {FIELD => "id"} ];
++ } else {
++ # For earlier versions, we have to list out all of the columns
++ $groups = [ map {+{FIELD => $_}} $self->Fields($table) ];
++ }
++ local $sb->{group_by} = $groups;
+ local $sb->{'order_by'} = [
+ map {
+ ($_->{'ALIAS'}||'') ne "main"
+--- lib/DBIx/SearchBuilder/Handle.pm 2013-06-06 23:06:18.000000000 +0400
++++ lib/DBIx/SearchBuilder/Handle.pm 2014-07-08 23:11:22.000000000 +0400
+@@ -1428,18 +1428,19 @@ sub DistinctCount {
+
+ sub Fields {
+ my $self = shift;
+- my $table = shift;
++ my $table = lc shift;
+
+- unless ( keys %FIELDS_IN_TABLE ) {
+- my $sth = $self->dbh->column_info( undef, '', '%', '%' )
++ unless ( $FIELDS_IN_TABLE{$table} ) {
++ $FIELDS_IN_TABLE{ $table } = [];
++ my $sth = $self->dbh->column_info( undef, '', $table, '%' )
+ or return ();
+ my $info = $sth->fetchall_arrayref({});
+ foreach my $e ( @$info ) {
+- push @{ $FIELDS_IN_TABLE{ lc $e->{'TABLE_NAME'} } ||= [] }, lc $e->{'COLUMN_NAME'};
++ push @{ $FIELDS_IN_TABLE{ $table } }, lc $e->{'COLUMN_NAME'};
+ }
+ }
+
+- return @{ $FIELDS_IN_TABLE{ lc $table } || [] };
++ return @{ $FIELDS_IN_TABLE{ $table } };
+ }
More information about the svn-ports-all
mailing list