[MDEV-9756] CREATE TRIGGER: no database selected (determine trigger location automatically based on the table location) Created: 2016-03-17  Updated: 2016-03-18

Status: Open
Project: MariaDB Server
Component/s: Triggers
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Federico Razzoli Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I have an application that runs queries like this:

CREATE TRIGGER t_ai
    AFTER INSERT
    ON test.t
    FOR EACH ROW
BEGIN
    INSERT INTO __test_changeset.t
            SET
                `id` = NEW.`id`,
                change_timestamp = NOW(6),
                change_type = 'INSERT'
        ;
END;

...and receives a "no database selected" error from MariaDB.

The error is technically correct, because the query does not specify in which database the trigger must be created. However it specifies in which database the table is, so the trigger needs to be there.

You may consider this as a funny feature request instead of a bug. However spending time to debug a query with a problem like this is not that funny... maybe this is easy to fix?

NOTE: I found this problem on 10.0, didn't check 10.1 or MySQL



 Comments   
Comment by Elena Stepanova [ 2016-03-18 ]

f_razzoli,

Something is missing or isn't right in your example – the trigger has a fully qualified name, it works regardless whether the current database is selected or not. Did you mean it to be just CREATE TRIGGER t_ai instead of CREATE TRIGGER test.t_ai?

Comment by Federico Razzoli [ 2016-03-18 ]

Sorry , yes I'm fixing the test case above

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