Bug #11139 replicate-rewrite-db/replicate-do-table doesn't honour aliases
Submitted: 7 Jun 2005 15:15 Modified: 30 Sep 2005 19:11
Reporter: Sergey Kostyliov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:mysql-4.1.12 OS:Linux (Gentoo Linux 2005.0 (ia32))
Assigned to: Bugs System CPU Architecture:Any

[7 Jun 2005 15:15] Sergey Kostyliov
Description:
Replication slave doesn't execute queries with aliases if replicate-rewrite-db/replicate-do-table  options are in use.

How to repeat:
Part of slave's my.cnf
...
replicate-rewrite-db            = "from-\>to"
replicate-do-table              = to.a
...

<master>
    mysql> \u from
    Database changed
        
    mysql> CREATE TABLE a (i INT);
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> INSERT INTO a VALUES(1);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> DELETE alias FROM a alias WHERE alias.i=1;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> SELECT * FROM a;
    Empty set (0.01 sec)
    
    mysql>
</master>

<slave>
    mysql> \u to
    Database changed
    mysql> SELECT * FROM a;
    +------+
    | i        |
    +------+
    |    1    |
    +------+
    1 row in set (0.00 sec)
    
    mysql>
</slave>

Suggested fix:
Work around: Do not use aliases in non-select queries for the time being.
[27 Aug 2005 23:14] Alexander Pachev
The problem is that tables_ok() gets improperly set up thd->lex->auxilliary_table_list - table->real_name points to table->alias. This in turn causes the rules to be applied to the alias instead of the real name. This can fixed quite easily, but I need to discuss my idea with other developers to make sure my fix does not break anything in their code, and if possible could correct other problems that step from this improper initialization, if there are any.
[14 Sep 2005 12:31] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29832
[25 Sep 2005 2:24] Alexander Pachev
Fixed in versions 4.1.15 and 5.0.14.
[30 Sep 2005 19:11] Paul Dubois
Noted in 4.1.15, 5.0.14 changelogs.