From 9430059d1d164a65b1c5b9ab1b013844a14d0cf1 Mon Sep 17 00:00:00 2001
From: Kieron Taylor <ktaylor@ebi.ac.uk>
Date: Mon, 1 Oct 2012 15:07:25 +0000
Subject: [PATCH] Fixed regression problem in fetch_by_region, where a valid
 synonym with an invalid coordinate system caused a never-ending loop. Added a
 coordinate system check to ensure the synonym query is on the correct
 coordinate system.

---
 modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
index 5f2dc2227c..3fdcb860e5 100644
--- a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+++ b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
@@ -291,14 +291,15 @@ sub fetch_by_region {
 
 
       # try synonyms
-      my $syn_sql_sth = $self->prepare("select s.name from seq_region s, seq_region_synonym ss where s.seq_region_id = ss.seq_region_id and ss.synonym = ?");
+      my $syn_sql_sth = $self->prepare("select s.name, s.coord_system_id from seq_region s, seq_region_synonym ss where s.seq_region_id = ss.seq_region_id and ss.synonym = ?");
       $syn_sql_sth->bind_param(1, $seq_region_name, SQL_VARCHAR);
       $syn_sql_sth->execute();
       my $new_name;
-      $syn_sql_sth->bind_columns( \$new_name);
+      my $new_coord_system;
+      $syn_sql_sth->bind_columns( \$new_name, \$new_coord_system);
       if($syn_sql_sth->fetch){
-	$syn_sql_sth->finish;
-	return $self->fetch_by_region($coord_system_name, $new_name, $start, $end, $strand, $version, $no_fuzz);
+        $syn_sql_sth->finish;
+        return $self->fetch_by_region($new_coord_system, $new_name, $start, $end, $strand, $version, $no_fuzz);
       }
       $syn_sql_sth->finish;
 
-- 
GitLab