For those of you who don't pore over the source of the MySQL client library as a form of recreation, there are a couple of settable option flags that change the behavior of libmysqlclient's connect and query functions.
These functions depend on the SHOW SLAVE HOSTS command displaying a valid list of slave hosts currently connected to a master server. For this command to work, each slave MySQL daemon(s) has to be started with the '--report-host=$STRING' option (this may be settable elsewhere, but there doesn't seem to be a default value...).
If all that's in place, then your client code does something like this:
mysql_init(&db); db.options.rpl_probe = (0|1); /* scan for slaves on connect */ db.options.rpl_parse = (0|1); /* route selects to slaves */ if(mysql_real_connect( ... ) ) { // do stuff! }
In this case, after connecting to the specified server, the client will guess at whether or not it's a master by running SHOW SLAVE STATUS (it will back out if it finds a running slave thread, apparently, but I haven't tested this), then try to run SHOW SLAVE HOSTS to build a slave host list.
If the rpl_parse flag is cleared, I don't think very much happens. But if the rpl_parse flag is set, then subsequent query() calls will be analyzed and routed to either the master or the first available slave connection.
In theory.
But I'm guessing there's a reason none of this is documented, and that reason is beer. Er, I mean, it's beta.
I've been lurking here for a while and haven't seen anyone mention this so far. It's not in the API documentation either. I confess I haven't combed through the recent changelogs, there may be something about it in there.
So has anyone played around with this? Or used it in production? I've tried it on a client app and it seems to work as advertised. Although when the slave "vanished," the client suddenly started trying to connect via a local UNIX socket every other query... (passing a null value to the connect(), I suppose)
If anyone knows anything about this proto-feature I'd love to hear about it...
Thanks, list. :)
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]