037038e736a88de87b00e5a384b29f45e831419f
braney
  Fri May 15 14:29:07 2026 -0700
fix Mysql "Commands out of sync" error on OMIM Genes (omimGene2) detail page

prGRShortRefGene runs its own queries on the supplied connection, so calling it
mid-iteration of an outer sqlMustGetResult loop on the same conn produced
"Commands out of sync; you can't run this command now". Slurp the gene names
into an slName list, free the outer result, then iterate, refs #37565

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 2cf3b71f6cc..b73b01f8f09 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -12236,39 +12236,45 @@
 		printf(", ");
             printf("<A HREF=\"%s%s&hgg_chrom=none\">", "../cgi-bin/hgGene?hgg_gene=", row[0]);
             printf("%s</A></B>", row[0]);
 	    printedCnt++;
 	    }
         if (printedCnt >= 1) printf("<BR>\n");
 	}
     sqlFreeResult(&sr);
 
     // show GeneReviews  link(s)
     if (sqlTableExists(conn, "geneReviewsDetail"))
         {
         sqlSafef(query, sizeof(query),
           "select distinct r.name2 from %s l, omim2gene g, refGene r where l.omimId=%s and g.geneId=l.locusLinkId and g.entryType='gene' and chrom='%s' and txStart = %s and txEnd= %s",
         refLinkTable, itemName, chrom, chromStart, chromEnd);
+        /* Slurp names first; prGRShortRefGene runs its own queries on conn,
+         * which would error with "Commands out of sync" mid-iteration. */
+        struct slName *geneNames = NULL;
         sr = sqlMustGetResult(conn, query);
         if (sr != NULL)
             {
             while ((row = sqlNextRow(sr)) != NULL)
-                {
-                prGRShortRefGene(conn, row[0]);
-                }
+                slNameAddHead(&geneNames, row[0]);
             }
         sqlFreeResult(&sr);
+        slReverse(&geneNames);
+        struct slName *gn;
+        for (gn = geneNames; gn != NULL; gn = gn->next)
+            prGRShortRefGene(conn, gn->name);
+        slFreeList(&geneNames);
         }
 
     showOmimDisorderTable(conn, url, itemName);
     }
 
 printf("</div>"); // #omimText
 }
 
 static void printOmimLocationDetails(struct trackDb *tdb, char *itemName, boolean encode)
 /* Print details of an OMIM Class 3 Gene entry. */
 {
 char *liftDb = cloneString(trackDbSetting(tdb, "quickLiftDb"));
 char *db = (liftDb == NULL) ? database : liftDb;
 struct sqlConnection *conn  = hAllocConn(db);
 struct sqlConnection *conn2 = hAllocConn(db);