提交 bc93aee3 authored 作者: Noel Grandin's avatar Noel Grandin

Merge remote-tracking branch 'upstream/master' into improve_script_exceptions

......@@ -23,6 +23,10 @@ Change Log
<ul>
<li>Improve the script-based unit testing to check the error code of the exception thrown.
</li>
<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
</li>
<li>Issue #873: No error when `=` in equal condition when column is not of array type
......
......@@ -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);
......
......@@ -166,6 +166,7 @@ public class Database implements DataHandler {
private final String cacheType;
private final String accessModeData;
private boolean referentialIntegrity = true;
/** ie. the MVCC setting */
private boolean multiVersion;
private DatabaseCloser closeOnExit;
private Mode mode = Mode.getRegular();
......@@ -279,13 +280,13 @@ public class Database implements DataHandler {
TraceSystem.DEFAULT_TRACE_LEVEL_SYSTEM_OUT);
this.cacheType = StringUtils.toUpperEnglish(
ci.removeProperty("CACHE_TYPE", Constants.CACHE_TYPE_DEFAULT));
openDatabase(traceLevelFile, traceLevelSystemOut, closeAtVmShutdown);
openDatabase(traceLevelFile, traceLevelSystemOut, closeAtVmShutdown, ci);
}
private void openDatabase(int traceLevelFile, int traceLevelSystemOut,
boolean closeAtVmShutdown) {
boolean closeAtVmShutdown, ConnectionInfo ci) {
try {
open(traceLevelFile, traceLevelSystemOut);
open(traceLevelFile, traceLevelSystemOut, ci);
if (closeAtVmShutdown) {
try {
closeOnExit = new DatabaseCloser(this, 0, true);
......@@ -608,7 +609,7 @@ public class Database implements DataHandler {
return dbSettings.databaseToUpper ? StringUtils.toUpperEnglish(n) : n;
}
private synchronized void open(int traceLevelFile, int traceLevelSystemOut) {
private synchronized void open(int traceLevelFile, int traceLevelSystemOut, ConnectionInfo ci) {
if (persistent) {
String dataFileName = databaseName + Constants.SUFFIX_OLD_DATABASE_FILE;
boolean existsData = FileUtils.exists(dataFileName);
......@@ -631,6 +632,9 @@ public class Database implements DataHandler {
}
if (existsPage && !existsMv) {
dbSettings.mvStore = false;
// Need to re-init this because the first time we do it we don't
// know if we have an mvstore or a pagestore.
multiVersion = ci.getProperty("MVCC", false);
}
if (readOnly) {
if (traceLevelFile >= TraceSystem.DEBUG) {
......
......@@ -6,7 +6,6 @@
package org.h2.engine;
import java.util.HashMap;
import org.h2.message.DbException;
import org.h2.util.Utils;
......
......@@ -108,7 +108,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 INVALID_PARAMETER_COUNT_2
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 ERROR_CREATING_TRIGGER_OBJECT_3
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 CANNOT_DROP_2
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论