Bug #27155 VERSION() function does not replicate correctly
Submitted: 14 Mar 2007 20:46 Modified: 16 Mar 2007 15:27
Reporter: Baron Schwartz (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0.26-standard-log OS:Linux (Linux)
Assigned to: MC Brown CPU Architecture:Any
Tags: replication

[14 Mar 2007 20:46] Baron Schwartz
Description:
The VERSION() function doesn't replicate correctly on servers of different versions.  It returns whatever version it runs on; to replicate correctly it would need to return the string returned on the master.

How to repeat:
Here I connect to the master and insert a value, then select it on the slave:

baron@kenya $ mysql -hmaster
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 85874 to server version: 5.0.26-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table versiontest(col varchar(50));
Query OK, 0 rows affected (0.03 sec)

mysql> insert into versiontest select version();
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from versiontest;
+---------------------+
| col                 |
+---------------------+
| 5.0.26-standard-log | 
+---------------------+
1 row in set (0.00 sec)

mysql> Bye

baron@kenya $ mysql -hslave
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 614 to server version: 5.0.26

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select * from versiontest;
+--------+
| col    |
+--------+
| 5.0.26 | 
+--------+
1 row in set (0.01 sec)

Suggested fix:
I'm not sure this is a bug.  It might just need to be included in the documentation on replication limitations and known problems, along with UUID() and the other functions that don't replicate correctly.
[14 Mar 2007 23:29] MySQL Verification Team
Thank you for the bug report. Verified as described.

master>select * from versiontest;
+------------------+
| col              |
+------------------+
| 5.0.38-debug-log | 
+------------------+
1 row in set (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: 192.168.0.33
                Master_User: miguel
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: binlog.000003
        Read_Master_Log_Pos: 334
             Relay_Log_File: skybr-relay-bin.000002
              Relay_Log_Pos: 232
      Relay_Master_Log_File: binlog.000003
           Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
            Replicate_Do_DB:
        Replicate_Ignore_DB:
         Replicate_Do_Table:
     Replicate_Ignore_Table:
    Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
                 Last_Errno: 0
                 Last_Error:
               Skip_Counter: 0
        Exec_Master_Log_Pos: 334
            Relay_Log_Space: 232
            Until_Condition: None
             Until_Log_File:
              Until_Log_Pos: 0
         Master_SSL_Allowed: No
         Master_SSL_CA_File:
         Master_SSL_CA_Path:
            Master_SSL_Cert:
          Master_SSL_Cipher:
             Master_SSL_Key:
      Seconds_Behind_Master: 0
1 row in set (0.00 sec)

mysql> use test
Database changed
mysql> select * from versiontest;
+---------------------+
| col                 |
+---------------------+
| 5.0.27-community-nt |
+---------------------+
1 row in set (0.01 sec)

mysql>
[16 Mar 2007 15:27] MC Brown
I've added this function to the list of those that are replicated verbatim (i.e. are executed on the slave locally) in: 

http://dev.mysql.com/doc/refman/5.0/en/replication-features.html
and:
http://dev.mysql.com/doc/refman/5.1/en/replication-features-functions.html