f8dee9637d2bd85c69bf7345c42f00d93cff407c maximilianh Fri Apr 1 11:05:40 2016 +0200 adding a comment in jksql.c, no redmine diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index ea4400e..0ea0749 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -1267,31 +1267,36 @@ // don't connect the failOver connection yet: lazily connect later when needed sc->failoverConn = sqlUnconnectedConn(failoverProf, database); return sc; } struct sqlConnection *sqlMayConnect(char *database) /* Connect to database on default host as default user. * Return NULL (don't abort) on failure. */ { return sqlConnProfile(sqlProfileMustGet(NULL, database), database, FALSE); } static boolean sqlConnectIfUnconnected(struct sqlConnection *sc, bool abort) /* Take a yet unconnected sqlConnection object and connect it to the sql server. - * returns TRUE on success, FALSE otherwise. */ + * returns TRUE on success, FALSE otherwise. + * This allows us to have mysql connection objects with a server name, port, + * database etc, but no actual mysql connection setup yet. The connection is + * only done when a query comes in. This saves a lot of time, as the failover + * connection object is just tracking the database changes on the main + * connection, and connects only when really necessary. */ { if (sc->conn!=NULL) return TRUE; char *profName = NULL; if (sc->profile) profName = sc->profile->name; struct sqlProfile *sp = sqlProfileMustGet(profName, sc->db); return (sqlConnRemoteFillIn(sc, sp, sc->db, abort, FALSE) != NULL); } struct sqlConnection *sqlConnect(char *database) /* Connect to database on default host as default user. */ { struct sqlProfile *defProf = sqlProfileMustGet(NULL, database); return sqlConnProfile(defProf, database, TRUE);