- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 584
Closed
dolthub/go-mysql-server
#2034Labels
analyzerbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersgood reproEasily reproducible bugsEasily reproducible bugssqlIssue with SQLIssue with SQL
Description
Dolt currently allows triggers to be created on a view, but they will never fire. MySQL also doesn't support running triggers on views, and does prevent trigger creation on views. Dolt should also disallow creating triggers on views.
Dolt behavior:
CREATE TABLE t (pk int primary key, col1 varchar(100), col2 varchar(200));
CREATE VIEW view2 AS select * from t;
DELIMITER // 
create trigger test_trigger AFTER INSERT on view2 FOR EACH ROW BEGIN update t set col1='CHANGED' where pk=1; END; //
show triggers; //
+--------------+--------+-------+---------------------------------------------------+--------+---------------------+----------+---------+----------------------+----------------------+--------------------+
| Trigger      | Event  | Table | Statement                                         | Timing | Created             | sql_mode | Definer | character_set_client | collation_connection | Database Collation |
+--------------+--------+-------+---------------------------------------------------+--------+---------------------+----------+---------+----------------------+----------------------+--------------------+
| test_trigger | INSERT | view2 | BEGIN update t set col1='CHANGED' where pk=1; END | AFTER  | 2023-08-01 18:08:38 |          |         | utf8mb4              | utf8mb4_0900_bin     | utf8mb4_0900_bin   |
+--------------+--------+-------+---------------------------------------------------+--------+---------------------+----------+---------+----------------------+----------------------+--------------------+MySQL behavior:
CREATE TABLE t (pk int primary key, col1 varchar(100), col2 varchar(200));
CREATE VIEW view2 AS select * from t;
DELIMITER // 
create trigger test_trigger AFTER INSERT on view2 FOR EACH ROW BEGIN update t set col1='CHANGED' where pk=1; END; //
ERROR 1347 (HY000): 'dolt.view2' is not BASE TABLEMetadata
Metadata
Assignees
Labels
analyzerbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersgood reproEasily reproducible bugsEasily reproducible bugssqlIssue with SQLIssue with SQL