提交 426737dd authored 作者: Noel Grandin's avatar Noel Grandin

create enums for ConstraintActionType and UnionType

上级 cad0c35a
...@@ -90,7 +90,7 @@ import org.h2.command.dml.Set; ...@@ -90,7 +90,7 @@ import org.h2.command.dml.Set;
import org.h2.command.dml.SetTypes; import org.h2.command.dml.SetTypes;
import org.h2.command.dml.TransactionCommand; import org.h2.command.dml.TransactionCommand;
import org.h2.command.dml.Update; import org.h2.command.dml.Update;
import org.h2.constraint.ConstraintReferential; import org.h2.constraint.ConstraintActionType;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.DbObject; import org.h2.engine.DbObject;
...@@ -1599,12 +1599,12 @@ public class Parser { ...@@ -1599,12 +1599,12 @@ public class Parser {
ifExists = readIfExists(ifExists); ifExists = readIfExists(ifExists);
command.setIfExists(ifExists); command.setIfExists(ifExists);
if (readIf("CASCADE")) { if (readIf("CASCADE")) {
command.setDropAction(ConstraintReferential.CASCADE); command.setDropAction(ConstraintActionType.CASCADE);
readIf("CONSTRAINTS"); readIf("CONSTRAINTS");
} else if (readIf("RESTRICT")) { } else if (readIf("RESTRICT")) {
command.setDropAction(ConstraintReferential.RESTRICT); command.setDropAction(ConstraintActionType.RESTRICT);
} else if (readIf("IGNORE")) { } else if (readIf("IGNORE")) {
command.setDropAction(ConstraintReferential.SET_DEFAULT); command.setDropAction(ConstraintActionType.SET_DEFAULT);
} }
return command; return command;
} else if (readIf("INDEX")) { } else if (readIf("INDEX")) {
...@@ -1654,7 +1654,7 @@ public class Parser { ...@@ -1654,7 +1654,7 @@ public class Parser {
command.setViewName(viewName); command.setViewName(viewName);
ifExists = readIfExists(ifExists); ifExists = readIfExists(ifExists);
command.setIfExists(ifExists); command.setIfExists(ifExists);
Integer dropAction = parseCascadeOrRestrict(); ConstraintActionType dropAction = parseCascadeOrRestrict();
if (dropAction != null) { if (dropAction != null) {
command.setDropAction(dropAction); command.setDropAction(dropAction);
} }
...@@ -1964,21 +1964,21 @@ public class Parser { ...@@ -1964,21 +1964,21 @@ public class Parser {
if (readIf("UNION")) { if (readIf("UNION")) {
SelectUnion union = new SelectUnion(session, command); SelectUnion union = new SelectUnion(session, command);
if (readIf("ALL")) { if (readIf("ALL")) {
union.setUnionType(SelectUnion.UNION_ALL); union.setUnionType(SelectUnion.UnionType.UNION_ALL);
} else { } else {
readIf("DISTINCT"); readIf("DISTINCT");
union.setUnionType(SelectUnion.UNION); union.setUnionType(SelectUnion.UnionType.UNION);
} }
union.setRight(parseSelectSub()); union.setRight(parseSelectSub());
command = union; command = union;
} else if (readIf("MINUS") || readIf("EXCEPT")) { } else if (readIf("MINUS") || readIf("EXCEPT")) {
SelectUnion union = new SelectUnion(session, command); SelectUnion union = new SelectUnion(session, command);
union.setUnionType(SelectUnion.EXCEPT); union.setUnionType(SelectUnion.UnionType.EXCEPT);
union.setRight(parseSelectSub()); union.setRight(parseSelectSub());
command = union; command = union;
} else if (readIf("INTERSECT")) { } else if (readIf("INTERSECT")) {
SelectUnion union = new SelectUnion(session, command); SelectUnion union = new SelectUnion(session, command);
union.setUnionType(SelectUnion.INTERSECT); union.setUnionType(SelectUnion.UnionType.INTERSECT);
union.setRight(parseSelectSub()); union.setRight(parseSelectSub());
command = union; command = union;
} else { } else {
...@@ -6382,28 +6382,28 @@ public class Parser { ...@@ -6382,28 +6382,28 @@ public class Parser {
return command; return command;
} }
private int parseAction() { private ConstraintActionType parseAction() {
Integer result = parseCascadeOrRestrict(); ConstraintActionType result = parseCascadeOrRestrict();
if (result != null) { if (result != null) {
return result; return result;
} }
if (readIf("NO")) { if (readIf("NO")) {
read("ACTION"); read("ACTION");
return ConstraintReferential.RESTRICT; return ConstraintActionType.RESTRICT;
} }
read("SET"); read("SET");
if (readIf("NULL")) { if (readIf("NULL")) {
return ConstraintReferential.SET_NULL; return ConstraintActionType.SET_NULL;
} }
read("DEFAULT"); read("DEFAULT");
return ConstraintReferential.SET_DEFAULT; return ConstraintActionType.SET_DEFAULT;
} }
private Integer parseCascadeOrRestrict() { private ConstraintActionType parseCascadeOrRestrict() {
if (readIf("CASCADE")) { if (readIf("CASCADE")) {
return ConstraintReferential.CASCADE; return ConstraintActionType.CASCADE;
} else if (readIf("RESTRICT")) { } else if (readIf("RESTRICT")) {
return ConstraintReferential.RESTRICT; return ConstraintActionType.RESTRICT;
} else { } else {
return null; return null;
} }
......
...@@ -10,6 +10,7 @@ import java.util.HashSet; ...@@ -10,6 +10,7 @@ import java.util.HashSet;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.constraint.Constraint; import org.h2.constraint.Constraint;
import org.h2.constraint.ConstraintActionType;
import org.h2.constraint.ConstraintCheck; import org.h2.constraint.ConstraintCheck;
import org.h2.constraint.ConstraintReferential; import org.h2.constraint.ConstraintReferential;
import org.h2.constraint.ConstraintUnique; import org.h2.constraint.ConstraintUnique;
...@@ -38,8 +39,8 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -38,8 +39,8 @@ public class AlterTableAddConstraint extends SchemaCommand {
private String constraintName; private String constraintName;
private String tableName; private String tableName;
private IndexColumn[] indexColumns; private IndexColumn[] indexColumns;
private int deleteAction; private ConstraintActionType deleteAction;
private int updateAction; private ConstraintActionType updateAction;
private Schema refSchema; private Schema refSchema;
private String refTableName; private String refTableName;
private IndexColumn[] refIndexColumns; private IndexColumn[] refIndexColumns;
...@@ -298,11 +299,11 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -298,11 +299,11 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
} }
public void setDeleteAction(int action) { public void setDeleteAction(ConstraintActionType action) {
this.deleteAction = action; this.deleteAction = action;
} }
public void setUpdateAction(int action) { public void setUpdateAction(ConstraintActionType action) {
this.updateAction = action; this.updateAction = action;
} }
......
...@@ -7,11 +7,10 @@ package org.h2.command.ddl; ...@@ -7,11 +7,10 @@ package org.h2.command.ddl;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.constraint.Constraint; import org.h2.constraint.Constraint;
import org.h2.constraint.ConstraintReferential; import org.h2.constraint.ConstraintActionType;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -31,13 +30,13 @@ public class DropTable extends SchemaCommand { ...@@ -31,13 +30,13 @@ public class DropTable extends SchemaCommand {
private String tableName; private String tableName;
private Table table; private Table table;
private DropTable next; private DropTable next;
private int dropAction; private ConstraintActionType dropAction;
public DropTable(Session session, Schema schema) { public DropTable(Session session, Schema schema) {
super(session, schema); super(session, schema);
dropAction = session.getDatabase().getSettings().dropRestrict ? dropAction = session.getDatabase().getSettings().dropRestrict ?
ConstraintReferential.RESTRICT : ConstraintActionType.RESTRICT :
ConstraintReferential.CASCADE; ConstraintActionType.CASCADE;
} }
/** /**
...@@ -75,7 +74,7 @@ public class DropTable extends SchemaCommand { ...@@ -75,7 +74,7 @@ public class DropTable extends SchemaCommand {
if (!table.canDrop()) { if (!table.canDrop()) {
throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName); throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName);
} }
if (dropAction == ConstraintReferential.RESTRICT) { if (dropAction == ConstraintActionType.RESTRICT) {
StatementBuilder buff = new StatementBuilder(); StatementBuilder buff = new StatementBuilder();
CopyOnWriteArrayList<TableView> dependentViews = table.getDependentViews(); CopyOnWriteArrayList<TableView> dependentViews = table.getDependentViews();
if (dependentViews != null && dependentViews.size() > 0) { if (dependentViews != null && dependentViews.size() > 0) {
...@@ -131,7 +130,7 @@ public class DropTable extends SchemaCommand { ...@@ -131,7 +130,7 @@ public class DropTable extends SchemaCommand {
return 0; return 0;
} }
public void setDropAction(int dropAction) { public void setDropAction(ConstraintActionType dropAction) {
this.dropAction = dropAction; this.dropAction = dropAction;
if (next != null) { if (next != null) {
next.setDropAction(dropAction); next.setDropAction(dropAction);
......
...@@ -8,7 +8,7 @@ package org.h2.command.ddl; ...@@ -8,7 +8,7 @@ package org.h2.command.ddl;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.constraint.ConstraintReferential; import org.h2.constraint.ConstraintActionType;
import org.h2.engine.DbObject; import org.h2.engine.DbObject;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -26,20 +26,20 @@ public class DropView extends SchemaCommand { ...@@ -26,20 +26,20 @@ public class DropView extends SchemaCommand {
private String viewName; private String viewName;
private boolean ifExists; private boolean ifExists;
private int dropAction; private ConstraintActionType dropAction;
public DropView(Session session, Schema schema) { public DropView(Session session, Schema schema) {
super(session, schema); super(session, schema);
dropAction = session.getDatabase().getSettings().dropRestrict ? dropAction = session.getDatabase().getSettings().dropRestrict ?
ConstraintReferential.RESTRICT : ConstraintActionType.RESTRICT :
ConstraintReferential.CASCADE; ConstraintActionType.CASCADE;
} }
public void setIfExists(boolean b) { public void setIfExists(boolean b) {
ifExists = b; ifExists = b;
} }
public void setDropAction(int dropAction) { public void setDropAction(ConstraintActionType dropAction) {
this.dropAction = dropAction; this.dropAction = dropAction;
} }
...@@ -61,7 +61,7 @@ public class DropView extends SchemaCommand { ...@@ -61,7 +61,7 @@ public class DropView extends SchemaCommand {
} }
session.getUser().checkRight(view, Right.ALL); session.getUser().checkRight(view, Right.ALL);
if (dropAction == ConstraintReferential.RESTRICT) { if (dropAction == ConstraintActionType.RESTRICT) {
for (DbObject child : view.getChildren()) { for (DbObject child : view.getChildren()) {
if (child instanceof TableView) { if (child instanceof TableView) {
throw DbException.get(ErrorCode.CANNOT_DROP_2, viewName, child.getName()); throw DbException.get(ErrorCode.CANNOT_DROP_2, viewName, child.getName());
......
...@@ -38,27 +38,29 @@ import org.h2.value.ValueNull; ...@@ -38,27 +38,29 @@ import org.h2.value.ValueNull;
*/ */
public class SelectUnion extends Query { public class SelectUnion extends Query {
public enum UnionType {
/** /**
* The type of a UNION statement. * The type of a UNION statement.
*/ */
public static final int UNION = 0; UNION,
/** /**
* The type of a UNION ALL statement. * The type of a UNION ALL statement.
*/ */
public static final int UNION_ALL = 1; UNION_ALL,
/** /**
* The type of an EXCEPT statement. * The type of an EXCEPT statement.
*/ */
public static final int EXCEPT = 2; EXCEPT,
/** /**
* The type of an INTERSECT statement. * The type of an INTERSECT statement.
*/ */
public static final int INTERSECT = 3; INTERSECT
}
private int unionType; private UnionType unionType;
/** /**
* The left hand side of the union (the first subquery). * The left hand side of the union (the first subquery).
...@@ -93,11 +95,11 @@ public class SelectUnion extends Query { ...@@ -93,11 +95,11 @@ public class SelectUnion extends Query {
right.prepareJoinBatch(); right.prepareJoinBatch();
} }
public void setUnionType(int type) { public void setUnionType(UnionType type) {
this.unionType = type; this.unionType = type;
} }
public int getUnionType() { public UnionType getUnionType() {
return unionType; return unionType;
} }
...@@ -178,7 +180,7 @@ public class SelectUnion extends Query { ...@@ -178,7 +180,7 @@ public class SelectUnion extends Query {
limitExpr = ValueExpression.get(ValueInt.get(l)); limitExpr = ValueExpression.get(ValueInt.get(l));
} }
if (session.getDatabase().getSettings().optimizeInsertFromSelect) { if (session.getDatabase().getSettings().optimizeInsertFromSelect) {
if (unionType == UNION_ALL && target != null) { if (unionType == UnionType.UNION_ALL && target != null) {
if (sort == null && !distinct && maxRows == 0 && if (sort == null && !distinct && maxRows == 0 &&
offsetExpr == null && limitExpr == null) { offsetExpr == null && limitExpr == null) {
left.query(0, target); left.query(0, target);
...@@ -188,7 +190,7 @@ public class SelectUnion extends Query { ...@@ -188,7 +190,7 @@ public class SelectUnion extends Query {
} }
} }
int columnCount = left.getColumnCount(); int columnCount = left.getColumnCount();
if (session.isLazyQueryExecution() && unionType == UNION_ALL && !distinct && if (session.isLazyQueryExecution() && unionType == UnionType.UNION_ALL && !distinct &&
sort == null && !randomAccessResult && !isForUpdate && sort == null && !randomAccessResult && !isForUpdate &&
offsetExpr == null && isReadOnly()) { offsetExpr == null && isReadOnly()) {
int limit = -1; int limit = -1;
......
/*
* 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
*/
package org.h2.constraint;
public enum ConstraintActionType {
/**
* The action is to restrict the operation.
*/
RESTRICT,
/**
* The action is to cascade the operation.
*/
CASCADE,
/**
* The action is to set the value to the default value.
*/
SET_DEFAULT,
/**
* The action is to set the value to NULL.
*/
SET_NULL
}
\ No newline at end of file
...@@ -33,30 +33,10 @@ import org.h2.value.ValueNull; ...@@ -33,30 +33,10 @@ import org.h2.value.ValueNull;
*/ */
public class ConstraintReferential extends Constraint { public class ConstraintReferential extends Constraint {
/**
* The action is to restrict the operation.
*/
public static final int RESTRICT = 0;
/**
* The action is to cascade the operation.
*/
public static final int CASCADE = 1;
/**
* The action is to set the value to the default value.
*/
public static final int SET_DEFAULT = 2;
/**
* The action is to set the value to NULL.
*/
public static final int SET_NULL = 3;
private IndexColumn[] columns; private IndexColumn[] columns;
private IndexColumn[] refColumns; private IndexColumn[] refColumns;
private int deleteAction; private ConstraintActionType deleteAction;
private int updateAction; private ConstraintActionType updateAction;
private Table refTable; private Table refTable;
private Index index; private Index index;
private Index refIndex; private Index refIndex;
...@@ -74,7 +54,7 @@ public class ConstraintReferential extends Constraint { ...@@ -74,7 +54,7 @@ public class ConstraintReferential extends Constraint {
return Constraint.REFERENTIAL; return Constraint.REFERENTIAL;
} }
private static void appendAction(StatementBuilder buff, int action) { private static void appendAction(StatementBuilder buff, ConstraintActionType action) {
switch (action) { switch (action) {
case CASCADE: case CASCADE:
buff.append("CASCADE"); buff.append("CASCADE");
...@@ -154,11 +134,11 @@ public class ConstraintReferential extends Constraint { ...@@ -154,11 +134,11 @@ public class ConstraintReferential extends Constraint {
if (internalIndex && refIndexOwner && forTable == this.table) { if (internalIndex && refIndexOwner && forTable == this.table) {
buff.append(" INDEX ").append(refIndex.getSQL()); buff.append(" INDEX ").append(refIndex.getSQL());
} }
if (deleteAction != RESTRICT) { if (deleteAction != ConstraintActionType.RESTRICT) {
buff.append(" ON DELETE "); buff.append(" ON DELETE ");
appendAction(buff, deleteAction); appendAction(buff, deleteAction);
} }
if (updateAction != RESTRICT) { if (updateAction != ConstraintActionType.RESTRICT) {
buff.append(" ON UPDATE "); buff.append(" ON UPDATE ");
appendAction(buff, updateAction); appendAction(buff, updateAction);
} }
...@@ -437,21 +417,21 @@ public class ConstraintReferential extends Constraint { ...@@ -437,21 +417,21 @@ public class ConstraintReferential extends Constraint {
} }
if (newRow == null) { if (newRow == null) {
// this is a delete // this is a delete
if (deleteAction == RESTRICT) { if (deleteAction == ConstraintActionType.RESTRICT) {
checkRow(session, oldRow); checkRow(session, oldRow);
} else { } else {
int i = deleteAction == CASCADE ? 0 : columns.length; int i = deleteAction == ConstraintActionType.CASCADE ? 0 : columns.length;
Prepared deleteCommand = getDelete(session); Prepared deleteCommand = getDelete(session);
setWhere(deleteCommand, i, oldRow); setWhere(deleteCommand, i, oldRow);
updateWithSkipCheck(deleteCommand); updateWithSkipCheck(deleteCommand);
} }
} else { } else {
// this is an update // this is an update
if (updateAction == RESTRICT) { if (updateAction == ConstraintActionType.RESTRICT) {
checkRow(session, oldRow); checkRow(session, oldRow);
} else { } else {
Prepared updateCommand = getUpdate(session); Prepared updateCommand = getUpdate(session);
if (updateAction == CASCADE) { if (updateAction == ConstraintActionType.CASCADE) {
ArrayList<Parameter> params = updateCommand.getParameters(); ArrayList<Parameter> params = updateCommand.getParameters();
for (int i = 0, len = columns.length; i < len; i++) { for (int i = 0, len = columns.length; i < len; i++) {
Parameter param = params.get(i); Parameter param = params.get(i);
...@@ -488,7 +468,7 @@ public class ConstraintReferential extends Constraint { ...@@ -488,7 +468,7 @@ public class ConstraintReferential extends Constraint {
} }
} }
public int getDeleteAction() { public ConstraintActionType getDeleteAction() {
return deleteAction; return deleteAction;
} }
...@@ -497,11 +477,11 @@ public class ConstraintReferential extends Constraint { ...@@ -497,11 +477,11 @@ public class ConstraintReferential extends Constraint {
* *
* @param action the action * @param action the action
*/ */
public void setDeleteAction(int action) { public void setDeleteAction(ConstraintActionType action) {
if (action == deleteAction && deleteSQL == null) { if (action == deleteAction && deleteSQL == null) {
return; return;
} }
if (deleteAction != RESTRICT) { if (deleteAction != ConstraintActionType.RESTRICT) {
throw DbException.get(ErrorCode.CONSTRAINT_ALREADY_EXISTS_1, "ON DELETE"); throw DbException.get(ErrorCode.CONSTRAINT_ALREADY_EXISTS_1, "ON DELETE");
} }
this.deleteAction = action; this.deleteAction = action;
...@@ -509,11 +489,11 @@ public class ConstraintReferential extends Constraint { ...@@ -509,11 +489,11 @@ public class ConstraintReferential extends Constraint {
} }
private void buildDeleteSQL() { private void buildDeleteSQL() {
if (deleteAction == RESTRICT) { if (deleteAction == ConstraintActionType.RESTRICT) {
return; return;
} }
StatementBuilder buff = new StatementBuilder(); StatementBuilder buff = new StatementBuilder();
if (deleteAction == CASCADE) { if (deleteAction == ConstraintActionType.CASCADE) {
buff.append("DELETE FROM ").append(table.getSQL()); buff.append("DELETE FROM ").append(table.getSQL());
} else { } else {
appendUpdate(buff); appendUpdate(buff);
...@@ -530,7 +510,7 @@ public class ConstraintReferential extends Constraint { ...@@ -530,7 +510,7 @@ public class ConstraintReferential extends Constraint {
return prepare(session, deleteSQL, deleteAction); return prepare(session, deleteSQL, deleteAction);
} }
public int getUpdateAction() { public ConstraintActionType getUpdateAction() {
return updateAction; return updateAction;
} }
...@@ -539,11 +519,11 @@ public class ConstraintReferential extends Constraint { ...@@ -539,11 +519,11 @@ public class ConstraintReferential extends Constraint {
* *
* @param action the action * @param action the action
*/ */
public void setUpdateAction(int action) { public void setUpdateAction(ConstraintActionType action) {
if (action == updateAction && updateSQL == null) { if (action == updateAction && updateSQL == null) {
return; return;
} }
if (updateAction != RESTRICT) { if (updateAction != ConstraintActionType.RESTRICT) {
throw DbException.get(ErrorCode.CONSTRAINT_ALREADY_EXISTS_1, "ON UPDATE"); throw DbException.get(ErrorCode.CONSTRAINT_ALREADY_EXISTS_1, "ON UPDATE");
} }
this.updateAction = action; this.updateAction = action;
...@@ -551,7 +531,7 @@ public class ConstraintReferential extends Constraint { ...@@ -551,7 +531,7 @@ public class ConstraintReferential extends Constraint {
} }
private void buildUpdateSQL() { private void buildUpdateSQL() {
if (updateAction == RESTRICT) { if (updateAction == ConstraintActionType.RESTRICT) {
return; return;
} }
StatementBuilder buff = new StatementBuilder(); StatementBuilder buff = new StatementBuilder();
...@@ -566,15 +546,15 @@ public class ConstraintReferential extends Constraint { ...@@ -566,15 +546,15 @@ public class ConstraintReferential extends Constraint {
buildDeleteSQL(); buildDeleteSQL();
} }
private Prepared prepare(Session session, String sql, int action) { private Prepared prepare(Session session, String sql, ConstraintActionType action) {
Prepared command = session.prepare(sql); Prepared command = session.prepare(sql);
if (action != CASCADE) { if (action != ConstraintActionType.CASCADE) {
ArrayList<Parameter> params = command.getParameters(); ArrayList<Parameter> params = command.getParameters();
for (int i = 0, len = columns.length; i < len; i++) { for (int i = 0, len = columns.length; i < len; i++) {
Column column = columns[i].column; Column column = columns[i].column;
Parameter param = params.get(i); Parameter param = params.get(i);
Value value; Value value;
if (action == SET_NULL) { if (action == ConstraintActionType.SET_NULL) {
value = ValueNull.INSTANCE; value = ValueNull.INSTANCE;
} else { } else {
Expression expr = column.getDefaultExpression(); Expression expr = column.getDefaultExpression();
......
...@@ -19,6 +19,7 @@ import java.util.HashMap; ...@@ -19,6 +19,7 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import org.h2.command.Command; import org.h2.command.Command;
import org.h2.constraint.Constraint; import org.h2.constraint.Constraint;
import org.h2.constraint.ConstraintActionType;
import org.h2.constraint.ConstraintCheck; import org.h2.constraint.ConstraintCheck;
import org.h2.constraint.ConstraintReferential; import org.h2.constraint.ConstraintReferential;
import org.h2.constraint.ConstraintUnique; import org.h2.constraint.ConstraintUnique;
...@@ -1913,15 +1914,15 @@ public class MetaTable extends Table { ...@@ -1913,15 +1914,15 @@ public class MetaTable extends Table {
return rows; return rows;
} }
private static int getRefAction(int action) { private static int getRefAction(ConstraintActionType action) {
switch (action) { switch (action) {
case ConstraintReferential.CASCADE: case CASCADE:
return DatabaseMetaData.importedKeyCascade; return DatabaseMetaData.importedKeyCascade;
case ConstraintReferential.RESTRICT: case RESTRICT:
return DatabaseMetaData.importedKeyRestrict; return DatabaseMetaData.importedKeyRestrict;
case ConstraintReferential.SET_DEFAULT: case SET_DEFAULT:
return DatabaseMetaData.importedKeySetDefault; return DatabaseMetaData.importedKeySetDefault;
case ConstraintReferential.SET_NULL: case SET_NULL:
return DatabaseMetaData.importedKeySetNull; return DatabaseMetaData.importedKeySetNull;
default: default:
throw DbException.throwInternalError("action="+action); throw DbException.throwInternalError("action="+action);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论