text: --
  -- Copyright (C) 2012 Ness Computing, Inc.
  --
  -- Licensed under the Apache License, Version 2.0 (the "License");
  -- you may not use this file except in compliance with the License.
  -- You may obtain a copy of the License at
  --
  -- http://www.apache.org/licenses/LICENSE-2.0
  --
  -- Unless required by applicable law or agreed to in writing, software
  -- distributed under the License is distributed on an "AS IS" BASIS,
  -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  -- See the License for the specific language governing permissions and
  -- limitations under the License.
  --
  
  CREATE TABLE test1(a1 INT);
  CREATE TABLE test2(a2 INT);
  CREATE TABLE test3(a3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
  CREATE TABLE test4(
    a4 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    b4 INT DEFAULT 0
  );
  
  delimiter |
  
  CREATE TRIGGER testref BEFORE INSERT ON test1
    FOR EACH ROW BEGIN
      INSERT INTO test2 SET a2 = NEW.a1;
      DELETE FROM test3 WHERE a3 = NEW.a1;
      UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
    END;
  |
  
  delimiter ;
  
  INSERT INTO test3 (a3) VALUES
    (NULL), (NULL), (NULL), (NULL), (NULL),
    (NULL), (NULL), (NULL), (NULL), (NULL);
  
  INSERT INTO test4 (a4) VALUES
    (0), (0), (0), (0), (0), (0), (0), (0), (0), (0);
  