7d1ff9d4eda3fd50ac1c009204e8c6e3e4ed578b
markd
  Mon Sep 30 17:59:27 2024 -0700
make missing database profile error message a bit clearer

diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index 8a5f154..77fedfd 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -195,31 +195,31 @@
     if (sameString(p->name,"crlPath"))
 	sp->crlPath = cloneString(value);
     if (sameString(p->name,"verifyServerCert"))
 	sp->verifyServerCert = cloneString(value);
     }
 return sp;
 }
 
 
 static void sqlProfileAssocDb(struct sqlProfile *sp, char *db)
 /* associate a db with a profile.  If it is already associated with this
  * profile, don't do anything.*/
 {
 struct sqlProfile *sp2 = hashFindVal(dbToProfile, db);
 if ((sp2 != NULL) && (sp2 != sp))
-    errAbort("databases %s already associated with profile %s, trying to associated it with %s",
+    errAbort("databases '%s' already associated with hg.conf database profile '%s.*', trying to associated it with '%s.*'",
              db, sp2->name, sp->name);
 if (sp2 == NULL)
     {
     hashAdd(dbToProfile, db, sp);
     slSafeAddHead(&sp->dbs, slNameNew(db));
     }
 }
 
 static void sqlProfileCreate(struct sqlProfile *sp)
 /* create a profile and add to global data structures */
 {
 hashAdd(profiles, sp->name, sp);
 if (sameString(sp->name, getDefaultProfileName()))
     defaultProfile = sp;  // save default
 }
@@ -303,31 +303,31 @@
         {
         *dot1 = '\0';
         sqlProfileAddProfIf(cname->name);
         *dot1 = '.';
         }
     }
 }
 
 void sqlProfileAddDb(char *profileName, char *db)
 /* add a mapping of db to profile.  If database is already associated with
  * this profile, it is ignored.  If it is associated with a different profile,
  * it is an error. */
 {
 struct sqlProfile *sp = hashFindVal(profiles, profileName);
 if (sp == NULL)
-    errAbort("can't find profile %s for database %s in hg.conf", profileName, db);
+    errAbort("can't find profile '%s.*' for database '%s' in hg.conf", profileName, db);
 sqlProfileAssocDb(sp, db);
 }
 
 static void sqlProfileAddDbs(struct slName *cnames)
 /* add mappings of db to profile from ${db}.${profile} entries.
  * would have liked to have automatically added ${profile}.db
  * entries, but backupcentral, etc, would map multiple profiles
  * to a databases, so this is done manually in hdb.c. */
 {
 struct slName *cname;
 for (cname = cnames; cname != NULL; cname = cname->next)
     {
     char *dot1 = strchr(cname->name, '.'); // first dot in name
     if ((dot1 != NULL) && sameString(dot1, ".profile"))
         {
@@ -346,32 +346,32 @@
 dbToProfile = hashNew(12);
 struct slName *cnames = cfgNames();
 sqlProfileAddProfs(cnames);
 sqlProfileAddDbs(cnames);
 slFreeList(&cnames);
 }
 
 static struct sqlProfile* sqlProfileFindByName(char *profileName, char *database)
 /* find a profile by name, checking that database matches if found */
 {
 struct sqlProfile* sp = hashFindVal(profiles, profileName);
 if (sp == NULL)
     return NULL;
 #if UNUSED // FIXME: this breaks hgHeatMap, enable when logicalDb removed
 if ((database != NULL) && (sp->dbs != NULL) && !slNameInList(sp->dbs, database))
-    errAbort("attempt to obtain SQL profile %s for database %s, "
-             "which is not associate with this database-specific profile",
+    errAbort("attempt to obtain SQL  profile '%s.*' for database '%s', "
+             "which is not associate with this database-specific profile (check hg.conf)",
              profileName, database);
 #endif
 return sp;
 }
 
 static struct sqlProfile* sqlProfileFindByDatabase(char *database)
 /* find a profile using database as profile name, return the default if not
  * found */
 {
 if (!database)
     return defaultProfile;
 struct sqlProfile *sp = hashFindVal(dbToProfile, database);
 if (sp == NULL)
     sp = defaultProfile;
 return sp;
@@ -407,41 +407,41 @@
 if (sp==NULL || sp->name==NULL)
     return NULL;
 char *failoverProfName = catTwoStrings(failoverProfPrefix, sp->name);
 struct sqlProfile *failoverProf = sqlProfileGet(failoverProfName, database);
 freez(&failoverProfName);
 return failoverProf;
 }
 
 static struct sqlProfile* sqlProfileMustGet(char *profileName, char *database)
 /* lookup a profile using the profile resolution algorithm or die trying */
 {
 struct sqlProfile* sp = sqlProfileGet(profileName, database);
 if (sp == NULL)
     {
     if (profileName == NULL)
-        errAbort("can't find mysql connection info for database %s in hg.conf or ~/.hg.conf, should have a default profile named \"db\", so values for at least db.host, "
+        errAbort("can't find mysql connection info for database '%s' in hg.conf or ~/.hg.conf, should have a default profile named 'db', so values for at least db.host, "
                 "db.user and db.password. See http://genomewiki.ucsc.edu/index.php/Hg.conf", database);
     else if (sameWord(profileName, "backupcentral"))
-        errAbort("can't find profile %s in hg.conf. This error most likely indicates that the "
+        errAbort("can't find profile '%s.*' in hg.conf. This error most likely indicates that the "
             "Genome Browser could not connect to MySQL/MariaDB. Either the databases server is not running"
             "or the database connection socket indicated in hg.conf is not the one used by your server.", 
             profileName);
     else if (database == NULL)
-        errAbort("can't find profile %s in hg.conf", profileName);
+        errAbort("can't find profile '%s.*' in hg.conf", profileName);
     else
-        errAbort("can't find profile %s for database %s in hg.conf", profileName, database);
+        errAbort("can't find profile '%s.*' for database '%s.*' in hg.conf", profileName, database);
     }
 return sp;
 }
 
 struct slName* sqlProfileGetNames()
 /* Get a list of all profile names. slFreeList result when done */
 {
 if (profiles == NULL)
     sqlProfileLoad();
 struct slName *names = NULL;
 struct hashCookie cookie = hashFirst(profiles);
 struct hashEl* hel;
 while ((hel = hashNext(&cookie)) != NULL)
     slAddHead(&names, slNameNew(hel->name));
 return names;
@@ -1163,34 +1163,34 @@
     monitorEnterTime = oldTime;
 
     char *extraMsg = "";
     if (sqlIsUcscServer())
         extraMsg = "We hate this error more than any other and may be already looking into it."
             "If there is no message on https://twitter.com/GenomeBrowser with the time when we expect it to be back: "
             "You can help us by telling us about the error, "
             "our email is genome-www@soe.ucsc.edu. We will fix it ASAP."
             "And even if this server is failing for a few more hours today, usually, one of our other three "
             "international mirrors is still "
             "working. The three mirrors are genome.ucsc.edu (US), genome-euro.ucsc.edu (Germany), genome-asia.ucsc.edu "
             "(Japan). You may not find your custom tracks and saved sessions there, but using another mirror should allow "
             "continuing your work while we are fixing the problem. ";
 
     if (abort)
-	errAbort("Couldn't connect to database %s on %s as %s.\n%s\n%s",
+	errAbort("Couldn't connect to database '%s' on '%s' as %s.\n%s\n%s",
 	    database, sp->host, sp->user, mysql_error(conn), extraMsg);
     else if (sqlParanoid)
-	fprintf(stderr, "Couldn't connect to database %s on %s as %s.  "
+	fprintf(stderr, "Couldn't connect to database '%s' on '%s' as '%s'.  "
 		"mysql: %s  pid=%ld\n",
 		database, sp->host, sp->user, mysql_error(conn), (long)getpid());
     return NULL;
     }
 
 /* Make sure the db is correct in the connect, think usually happens if there
  * is a mismatch between MySQL library and code.  If this happens, please
  * figure out what is going on.  Contact markd if you need help. */
 if (((conn->db != NULL) && !sameString(database, conn->db))
    || ((conn->db == NULL) && (database != NULL)))
    errAbort("apparent mismatch between mysql.h used to compile jksql.c and libmysqlclient");
 
 sc->db=cloneString(database);
 if (monitorFlags & JKSQL_TRACE)
     monitorPrint(sc, "SQL_CONNECT", "%s %s", sp->host, sp->user);
@@ -2877,35 +2877,35 @@
     assert(!abort);
     return NULL;
     }
 }
 
 static struct sqlConnection *sqlConnCacheDoAlloc(struct sqlConnCache *cache,
                                                  char *profileName,
                                                  char *database,
                                                  boolean abort)
 /* Allocate a cached connection. errAbort if too many open connections.
  * errAbort if abort and connection fails. */
 {
 // obtain profile
 struct sqlProfile *profile = NULL;
 if ((cache->host != NULL) && (profileName != NULL))
-    errAbort("can't specify profileName (%s) when sqlConnCache is create with a specific host (%s)",
+    errAbort("can't specify profileName '%s' when sqlConnCache is create with a specific host '%s'",
              profileName, cache->host);
 if ((profileName != NULL) && (cache->profile != NULL)
     && !sameString(profileName, cache->profile->name))
-    errAbort("profile name %s doesn't match profile associated with sqlConnCache %s",
+    errAbort("profile name '%s' doesn't match profile associated with sqlConnCache '%s'",
              profileName, cache->profile->name);
 if (cache->profile != NULL)
     profile = cache->profile;
 else
     profile = sqlProfileMustGet(profileName, database);
 
 // try getting an entry, first trying to find one for this database, then
 // look for any database, then add a new one
 struct sqlConnCacheEntry *scce
     = sqlConnCacheFindFree(cache, profile, database, TRUE);
 if (scce == NULL)
     {
     scce = sqlConnCacheFindFree(cache, profile, database, FALSE);
     if (scce != NULL)
         {