Unverified 提交 e008b6c7 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #1079 from grandinj/1041_trigger

1041 trigger
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Issue #1041: Support OR syntax while creating trigger
</li>
<li>Issue #1023: MVCC and existing page store file
</li>
<li>Issue #1003: Decrypting database with incorrect password renders the database corrupt
......
......@@ -5082,7 +5082,9 @@ public class Parser {
} else {
throw getSyntaxError();
}
} while (readIf(","));
} while (readIf(",")
|| (database.getMode().getEnum() == ModeEnum.PostgreSQL
&& readIf("OR")));
read("ON");
String tableName = readIdentifierWithSchema();
checkSchema(schema);
......
......@@ -103,7 +103,7 @@ public class TestScript extends TestBase {
testScript("datatypes/" + s + ".sql");
}
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn",
"createAlias", "createView", "createTable",
"createAlias", "createView", "createTable", "createTrigger",
"dropSchema" }) {
testScript("ddl/" + s + ".sql");
}
......
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE TABLE COUNT(X INT);
> ok
CREATE FORCE TRIGGER T_COUNT BEFORE INSERT ON COUNT CALL "com.Unknown";
> ok
INSERT INTO COUNT VALUES(NULL);
> exception
DROP TRIGGER T_COUNT;
> ok
CREATE TABLE ITEMS(ID INT CHECK ID < SELECT MAX(ID) FROM COUNT);
> ok
insert into items values(DEFAULT);
> update count: 1
DROP TABLE COUNT;
> exception
insert into items values(DEFAULT);
> update count: 1
drop table items, count;
> ok
-- ---------------------------------------------------------------------------
-- PostgreSQL syntax tests
-- ---------------------------------------------------------------------------
set mode postgresql;
> ok
CREATE TABLE COUNT(X INT);
> ok
INSERT INTO COUNT VALUES(1);
> update count: 1
CREATE FORCE TRIGGER T_COUNT BEFORE INSERT OR UPDATE ON COUNT CALL "com.Unknown";
> ok
INSERT INTO COUNT VALUES(NULL);
> exception
UPDATE COUNT SET X=2 WHERE X=1;
> exception
......@@ -1391,33 +1391,6 @@ drop table test;
select rtrim() from dual;
> exception
CREATE TABLE COUNT(X INT);
> ok
CREATE FORCE TRIGGER T_COUNT BEFORE INSERT ON COUNT CALL "com.Unknown";
> ok
INSERT INTO COUNT VALUES(NULL);
> exception
DROP TRIGGER T_COUNT;
> ok
CREATE TABLE ITEMS(ID INT CHECK ID < SELECT MAX(ID) FROM COUNT);
> ok
insert into items values(DEFAULT);
> update count: 1
DROP TABLE COUNT;
> exception
insert into items values(DEFAULT);
> update count: 1
drop table items, count;
> ok
CREATE TABLE TEST(ID INT PRIMARY KEY, LABEL CHAR(20), LOOKUP CHAR(30));
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论