From 730c0d4300c26a8da91b9fdc8813be87c0e2d3c8 Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Fri, 3 Nov 2023 09:35:16 +0800 Subject: [PATCH] feat: support show create event, trigger and procedure in mysql --- pegjs/mariadb.pegjs | 2 +- pegjs/mysql.pegjs | 2 +- test/mysql-mariadb.spec.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pegjs/mariadb.pegjs b/pegjs/mariadb.pegjs index b6b0d69c..246a0977 100644 --- a/pegjs/mariadb.pegjs +++ b/pegjs/mariadb.pegjs @@ -1350,7 +1350,7 @@ show_stmt } }; } - / KW_SHOW __ KW_CREATE __ k:(KW_VIEW / KW_TABLE) __ t:table_name { + / KW_SHOW __ KW_CREATE __ k:(KW_VIEW / KW_TABLE / 'EVENT'i / KW_TRIGGER / 'PROCEDURE'i) __ t:table_name { const suffix = k.toLowerCase() return { tableList: Array.from(tableList), diff --git a/pegjs/mysql.pegjs b/pegjs/mysql.pegjs index e5e16426..e57b3075 100644 --- a/pegjs/mysql.pegjs +++ b/pegjs/mysql.pegjs @@ -1656,7 +1656,7 @@ show_stmt } }; } - / KW_SHOW __ KW_CREATE __ k:(KW_VIEW / KW_TABLE) __ t:table_name { + / KW_SHOW __ KW_CREATE __ k:(KW_VIEW / KW_TABLE / 'EVENT'i / KW_TRIGGER / 'PROCEDURE'i) __ t:table_name { const suffix = k.toLowerCase() return { tableList: Array.from(tableList), diff --git a/test/mysql-mariadb.spec.js b/test/mysql-mariadb.spec.js index 2e5bee70..8ba34521 100644 --- a/test/mysql-mariadb.spec.js +++ b/test/mysql-mariadb.spec.js @@ -342,6 +342,20 @@ describe('mysql', () => { 'SHOW CREATE VIEW `abc`.`test`' ] }, + { + title: 'show create event', + sql: [ + 'SHOW CREATE EVENT `monthly_gc`', + 'SHOW CREATE EVENT `monthly_gc`' + ] + }, + { + title: 'show create procedure', + sql: [ + 'SHOW CREATE PROCEDURE get_jails', + 'SHOW CREATE PROCEDURE `get_jails`' + ] + }, { title: 'with', sql: [