Regarding number 1, you might be able to do something with this:

        mysql> show variables like 'pid%';
        +---------------+-----------------------------------------+
        | Variable_name | Value                                   |
        +---------------+-----------------------------------------+
        | pid_file      | /var/lib/mysql/tatooine.xyzcorp.com.pid |
        +---------------+-----------------------------------------+

Regarding number 2 (as well as #1), my inclination is to reach for perl, but I don't know if that's an option for you.

HTH,

Ted

At 11:01 PM 10/6/2004, you wrote:
        I have 2 unrelated questions:

        1) Is there any way to get the hostname that the server is
        running on from within mysql?

        All I can come up with is (pseudo coded):

mysql> system echo insert mysql.hostname `hostname` ... > hostname.sql
mysql> source hostname.sql


        Does mysql make it available as a variable somewhere? I have scoured
        the docs to find nothing obvious.

        Note that I am not interested in where I am connected from
        (select user();).

        2) Is there a way to exit an sql script at the top of the
        script if it turns out that it is running on a slave in a
        replication scenario?

        ... something like:

        if slave then exit;
        (followed by more sql)

        A 'show slave status' dumps something like a table, but I don't
        see how to save any of the info in a variable that I might
        later use in a case statement. Basically, if the results of
        show slave status aren't zip, I should exit because I am the/a
        slave.

Thanks for any clues!

Brian

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to