Bug #46614 Assertion in show_create_trigger() on SHOW CREATE TRIGGER + MERGE table
Submitted: 8 Aug 2009 8:40 Modified: 18 Dec 2009 13:14
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1,5.4 OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any

[8 Aug 2009 8:40] Philip Stoev
Description:
Using SHOW CREATE TRIGGER on a trigger that is installed on a MERGE TABLE causes the following assertion:

mysqld: sql_show.cc:7101: bool show_create_trigger(THD*, const sp_name*): Assertion `num_tables == 1' failed.

#6  0x000000315a42bec9 in __assert_fail () from /lib64/libc.so.6
#7  0x00000000007b7951 in show_create_trigger (thd=0x28d9eb8, trg_name=0x2941fc0) at sql_show.cc:7101
#8  0x000000000065b4f1 in mysql_execute_command (thd=0x28d9eb8) at sql_parse.cc:4599
#9  0x000000000065ca17 in mysql_parse (thd=0x28d9eb8, inBuf=0x2941f08 "SHOW CREATE TRIGGER tr1_4_A", length=27, found_semicolon=0x7f46e7fe2ee0)
    at sql_parse.cc:5932
#10 0x000000000065d841 in dispatch_command (command=COM_QUERY, thd=0x28d9eb8, packet=0x292e4c9 "SHOW CREATE TRIGGER tr1_4_A", packet_length=27)
    at sql_parse.cc:1213
#11 0x000000000065ec26 in do_command (thd=0x28d9eb8) at sql_parse.cc:854
#12 0x000000000064b521 in handle_one_connection (arg=0x28d9eb8) at sql_connect.cc:1127
#13 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
#14 0x000000315a4e627d in clone () from /lib64/libc.so.6

How to repeat:
CREATE TABLE `table1_int_autoinc` ( `int` int, pk integer auto_increment, `int_key` int,        primary key (pk), key (`int_key` ));

CREATE TABLE IF NOT EXISTS t1_base_1_A LIKE test . table1_int_autoinc ;
CREATE TABLE IF NOT EXISTS t1_base_0_A LIKE test . table1_int_autoinc ;
CREATE TABLE IF NOT EXISTS t1_merge_1_A LIKE test . table1_int_autoinc ;
ALTER TABLE t1_merge_1_A ENGINE = MERGE UNION ( t1_base_1_A , t1_base_0_A );

CREATE TRIGGER tr1_4_A  AFTER INSERT ON t1_merge_1_A FOR EACH ROW CALL foo();

SHOW CREATE TRIGGER tr1_4_A;
[11 Aug 2009 5:06] 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/commits/80517

3062 Ramil Kalimullin	2009-08-11
      Fix for bug #46614: Assertion in show_create_trigger() 
      on SHOW CREATE TRIGGER + MERGE table
      
      Problem: SHOW CREATE TRIGGER erroneously relies on fact
      that we have the only underlying table for a trigger
      (wrong for merge tables).
      
      Fix: remove erroneous assert().
     @ mysql-test/r/merge.result
        Fix for bug #46614: Assertion in show_create_trigger() 
        on SHOW CREATE TRIGGER + MERGE table
          - test result.
     @ mysql-test/t/merge.test
        Fix for bug #46614: Assertion in show_create_trigger() 
        on SHOW CREATE TRIGGER + MERGE table
          - test case.
     @ sql/sql_show.cc
        Fix for bug #46614: Assertion in show_create_trigger() 
        on SHOW CREATE TRIGGER + MERGE table
          - unnecessary assert() removed as we may have more than 1 
        tables open e.g. for a merge table.
[13 Aug 2009 19:50] 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/commits/80779

3068 Ramil Kalimullin	2009-08-14
      Fix for bug #46614: Assertion in show_create_trigger() 
      on SHOW CREATE TRIGGER + MERGE table
      
      Problem: SHOW CREATE TRIGGER erroneously relies on fact
      that we have the only underlying table for a trigger
      (wrong for merge tables).
      
      Fix: remove erroneous assert().
     @ mysql-test/r/merge.result
        Fix for bug #46614: Assertion in show_create_trigger() 
        on SHOW CREATE TRIGGER + MERGE table
          - test result.
     @ mysql-test/t/merge.test
        Fix for bug #46614: Assertion in show_create_trigger() 
        on SHOW CREATE TRIGGER + MERGE table
          - test case.
     @ sql/sql_show.cc
        Fix for bug #46614: Assertion in show_create_trigger() 
        on SHOW CREATE TRIGGER + MERGE table
          - unnecessary assert() removed as we may have more than 1 
        tables open e.g. for a merge table.
[2 Sep 2009 16:42] Bugs System
Pushed into 5.1.39 (revid:joro@sun.com-20090902154533-8actmfcsjfqovgsb) (version source revid:ramil@mysql.com-20090813194928-3djdqvpock0pxhgp) (merge vers: 5.1.38) (pib:11)
[14 Sep 2009 16:06] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (version source revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (merge vers: 5.4.4-alpha) (pib:11)
[18 Sep 2009 19:35] Paul Dubois
Noted in 5.1.89, 5.4.4 changelogs.

SHOW CREATE TRIGGER for a MERGE table trigger caused an assertion
failure.
[1 Oct 2009 5:59] Bugs System
Pushed into 5.1.39-ndb-6.3.28 (revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (version source revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (merge vers: 5.1.39-ndb-6.3.28) (pib:11)
[1 Oct 2009 7:25] Bugs System
Pushed into 5.1.39-ndb-7.0.9 (revid:jonas@mysql.com-20091001072547-kv17uu06hfjhgjay) (version source revid:jonas@mysql.com-20091001071652-irejtnumzbpsbgk2) (merge vers: 5.1.39-ndb-7.0.9) (pib:11)
[1 Oct 2009 13:25] Bugs System
Pushed into 5.1.39-ndb-7.1.0 (revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (version source revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (merge vers: 5.1.39-ndb-7.1.0) (pib:11)
[2 Oct 2009 1:27] Paul Dubois
Moved 5.4 changelog entry from 5.4.4 to 5.4.3.
[5 Oct 2009 10:50] Bugs System
Pushed into 5.1.39-ndb-6.2.19 (revid:jonas@mysql.com-20091005103850-dwij2dojwpvf5hi6) (version source revid:jonas@mysql.com-20090930185117-bhud4ek1y0hsj1nv) (merge vers: 5.1.39-ndb-6.2.19) (pib:11)
[13 Oct 2009 18:30] Bugs System
Pushed into 5.1.41 (revid:build@mysql.com-20091013182142-vgsjky3t1v4btufv) (version source revid:build@mysql.com-20091013182142-vgsjky3t1v4btufv) (merge vers: 5.1.41) (pib:13)
[13 Oct 2009 23:33] Paul Dubois
Already noted in 5.1.39 changelog. ([18 Sep 21:35] entry should say 5.1.39, not 5.1.89)
[22 Oct 2009 6:37] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091022063126-l0qzirh9xyhp0bpc) (version source revid:alik@sun.com-20091019135554-s1pvptt6i750lfhv) (merge vers: 6.0.14-alpha) (pib:13)
[22 Oct 2009 7:09] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091022060553-znkmxm0g0gm6ckvw) (version source revid:alik@sun.com-20091019131937-nchb8tjk88jpfjav) (merge vers: 5.5.0-beta) (pib:13)
[22 Oct 2009 19:13] Paul Dubois
Noted in 5.5.0, 6.0.14 changelogs.
[18 Dec 2009 10:39] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:55] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:09] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:23] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)
[18 Dec 2009 13:14] MC Brown
Already documented in 5.1.41