[MDEV-10911] Make SHOW TRIGGERS to show triggers' action order Created: 2016-09-27  Updated: 2016-09-29  Resolved: 2016-09-29

Status: Closed
Project: MariaDB Server
Component/s: Triggers
Fix Version/s: N/A

Type: Task Priority: Minor
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-6112 multiple triggers per table Closed

 Description   

Currently SHOW TRIGGERS does not show the action order of triggers.

MariaDB [test]> show triggers like 't1' \G
*************************** 1. row ***************************
             Trigger: tr1
               Event: INSERT
               Table: t1
           Statement: insert into tlog values (now(),'INSERT',new.c)
              Timing: AFTER
             Created: 2016-09-28 01:42:07.43
            sql_mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
             Definer: root@localhost
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci
*************************** 2. row ***************************
             Trigger: tr0
               Event: INSERT
               Table: t1
           Statement: insert into tlog values (now(),'INSERT',new.c)
              Timing: AFTER
             Created: 2016-09-28 01:42:23.27
            sql_mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
             Definer: root@localhost
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci
*************************** 3. row ***************************
             Trigger: tr2
               Event: INSERT
               Table: t1
           Statement: insert into tlog values (now(),'INSERT',new.c)
              Timing: AFTER
             Created: 2016-09-28 01:36:05.20
            sql_mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
             Definer: root@localhost
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci
3 rows in set (0.01 sec)

It's not critical, since it can be found from INFORMATION_SCHEMA.TRIGGERS:

MariaDB [test]> select * from information_schema.triggers \G
*************************** 1. row ***************************
           TRIGGER_CATALOG: def
            TRIGGER_SCHEMA: test
              TRIGGER_NAME: tr1
        EVENT_MANIPULATION: INSERT
      EVENT_OBJECT_CATALOG: def
       EVENT_OBJECT_SCHEMA: test
        EVENT_OBJECT_TABLE: t1
              ACTION_ORDER: 1
          ACTION_CONDITION: NULL
          ACTION_STATEMENT: insert into tlog values (now(),'INSERT',new.c)
        ACTION_ORIENTATION: ROW
             ACTION_TIMING: AFTER
ACTION_REFERENCE_OLD_TABLE: NULL
ACTION_REFERENCE_NEW_TABLE: NULL
  ACTION_REFERENCE_OLD_ROW: OLD
  ACTION_REFERENCE_NEW_ROW: NEW
                   CREATED: 2016-09-28 01:42:07.43
                  SQL_MODE: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
                   DEFINER: root@localhost
      CHARACTER_SET_CLIENT: utf8
      COLLATION_CONNECTION: utf8_general_ci
        DATABASE_COLLATION: latin1_swedish_ci
*************************** 2. row ***************************
           TRIGGER_CATALOG: def
            TRIGGER_SCHEMA: test
              TRIGGER_NAME: tr0
        EVENT_MANIPULATION: INSERT
      EVENT_OBJECT_CATALOG: def
       EVENT_OBJECT_SCHEMA: test
        EVENT_OBJECT_TABLE: t1
              ACTION_ORDER: 2
          ACTION_CONDITION: NULL
          ACTION_STATEMENT: insert into tlog values (now(),'INSERT',new.c)
        ACTION_ORIENTATION: ROW
             ACTION_TIMING: AFTER
ACTION_REFERENCE_OLD_TABLE: NULL
ACTION_REFERENCE_NEW_TABLE: NULL
  ACTION_REFERENCE_OLD_ROW: OLD
  ACTION_REFERENCE_NEW_ROW: NEW
                   CREATED: 2016-09-28 01:42:23.27
                  SQL_MODE: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
                   DEFINER: root@localhost
      CHARACTER_SET_CLIENT: utf8
      COLLATION_CONNECTION: utf8_general_ci
        DATABASE_COLLATION: latin1_swedish_ci
*************************** 3. row ***************************
           TRIGGER_CATALOG: def
            TRIGGER_SCHEMA: test
              TRIGGER_NAME: tr2
        EVENT_MANIPULATION: INSERT
      EVENT_OBJECT_CATALOG: def
       EVENT_OBJECT_SCHEMA: test
        EVENT_OBJECT_TABLE: t1
              ACTION_ORDER: 3
          ACTION_CONDITION: NULL
          ACTION_STATEMENT: insert into tlog values (now(),'INSERT',new.c)
        ACTION_ORIENTATION: ROW
             ACTION_TIMING: AFTER
ACTION_REFERENCE_OLD_TABLE: NULL
ACTION_REFERENCE_NEW_TABLE: NULL
  ACTION_REFERENCE_OLD_ROW: OLD
  ACTION_REFERENCE_NEW_ROW: NEW
                   CREATED: 2016-09-28 01:36:05.20
                  SQL_MODE: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
                   DEFINER: root@localhost
      CHARACTER_SET_CLIENT: utf8
      COLLATION_CONNECTION: utf8_general_ci
        DATABASE_COLLATION: latin1_swedish_ci
3 rows in set (0.01 sec)

Still, it would make sense to have it in SHOW TRIGGERS.

Update:
It turns out that the MySQL's MTR test case actually has a test which checks, specifically, that ACTION_ORDER is not displayed in SHOW output. I am not sure why, though.

# Test 5.
# Check that action_order attribute isn't shown 
# in the output of SHOW TRIGGERS and SHOW CREATE TRIGGER



 Comments   
Comment by Michael Widenius [ 2016-09-29 ]

I don't think that action order is important for SHOW TRIGGERS as triggers is always listed in action order in MariaDB. Better to keep the output identical to MySQL 5.7

Comment by Michael Widenius [ 2016-09-29 ]

No reason to fix as triggers are displayed in action order

Generated at Thu Feb 08 07:45:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.