提交 f2844c7c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use domain term everywhere, UDT in H2 are actually domains

上级 e764c254
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Literals of this kind are not allowed 90116=Literals of this kind are not allowed
90117=Remote connections to this server are not allowed, see -tcpAllowOthers 90117=Remote connections to this server are not allowed, see -tcpAllowOthers
90118=Cannot drop table {0} 90118=Cannot drop table {0}
90119=User data type {0} already exists 90119=Domain {0} already exists
90120=User data type {0} not found 90120=Domain {0} not found
90121=Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) 90121=Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL)
90122=The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Cannot mix indexed and non-indexed parameters 90123=Cannot mix indexed and non-indexed parameters
......
...@@ -1748,7 +1748,7 @@ public class ErrorCode { ...@@ -1748,7 +1748,7 @@ public class ErrorCode {
* CREATE DOMAIN EMAIL AS VARCHAR CHECK LOCATE('@', VALUE) > 0; * CREATE DOMAIN EMAIL AS VARCHAR CHECK LOCATE('@', VALUE) > 0;
* </pre> * </pre>
*/ */
public static final int USER_DATA_TYPE_ALREADY_EXISTS_1 = 90119; public static final int DOMAIN_ALREADY_EXISTS_1 = 90119;
/** /**
* The error with code <code>90120</code> is thrown when * The error with code <code>90120</code> is thrown when
...@@ -1758,7 +1758,7 @@ public class ErrorCode { ...@@ -1758,7 +1758,7 @@ public class ErrorCode {
* DROP DOMAIN UNKNOWN; * DROP DOMAIN UNKNOWN;
* </pre> * </pre>
*/ */
public static final int USER_DATA_TYPE_NOT_FOUND_1 = 90120; public static final int DOMAIN_NOT_FOUND_1 = 90120;
/** /**
* The error with code <code>90121</code> is thrown when * The error with code <code>90121</code> is thrown when
......
...@@ -78,6 +78,7 @@ import org.h2.command.ddl.Analyze; ...@@ -78,6 +78,7 @@ import org.h2.command.ddl.Analyze;
import org.h2.command.ddl.CommandWithColumns; import org.h2.command.ddl.CommandWithColumns;
import org.h2.command.ddl.CreateAggregate; import org.h2.command.ddl.CreateAggregate;
import org.h2.command.ddl.CreateConstant; import org.h2.command.ddl.CreateConstant;
import org.h2.command.ddl.CreateDomain;
import org.h2.command.ddl.CreateFunctionAlias; import org.h2.command.ddl.CreateFunctionAlias;
import org.h2.command.ddl.CreateIndex; import org.h2.command.ddl.CreateIndex;
import org.h2.command.ddl.CreateLinkedTable; import org.h2.command.ddl.CreateLinkedTable;
...@@ -88,13 +89,13 @@ import org.h2.command.ddl.CreateSynonym; ...@@ -88,13 +89,13 @@ import org.h2.command.ddl.CreateSynonym;
import org.h2.command.ddl.CreateTable; import org.h2.command.ddl.CreateTable;
import org.h2.command.ddl.CreateTrigger; import org.h2.command.ddl.CreateTrigger;
import org.h2.command.ddl.CreateUser; import org.h2.command.ddl.CreateUser;
import org.h2.command.ddl.CreateUserDataType;
import org.h2.command.ddl.CreateView; import org.h2.command.ddl.CreateView;
import org.h2.command.ddl.DeallocateProcedure; import org.h2.command.ddl.DeallocateProcedure;
import org.h2.command.ddl.DefineCommand; import org.h2.command.ddl.DefineCommand;
import org.h2.command.ddl.DropAggregate; import org.h2.command.ddl.DropAggregate;
import org.h2.command.ddl.DropConstant; import org.h2.command.ddl.DropConstant;
import org.h2.command.ddl.DropDatabase; import org.h2.command.ddl.DropDatabase;
import org.h2.command.ddl.DropDomain;
import org.h2.command.ddl.DropFunctionAlias; import org.h2.command.ddl.DropFunctionAlias;
import org.h2.command.ddl.DropIndex; import org.h2.command.ddl.DropIndex;
import org.h2.command.ddl.DropRole; import org.h2.command.ddl.DropRole;
...@@ -104,7 +105,6 @@ import org.h2.command.ddl.DropSynonym; ...@@ -104,7 +105,6 @@ import org.h2.command.ddl.DropSynonym;
import org.h2.command.ddl.DropTable; import org.h2.command.ddl.DropTable;
import org.h2.command.ddl.DropTrigger; import org.h2.command.ddl.DropTrigger;
import org.h2.command.ddl.DropUser; import org.h2.command.ddl.DropUser;
import org.h2.command.ddl.DropUserDataType;
import org.h2.command.ddl.DropView; import org.h2.command.ddl.DropView;
import org.h2.command.ddl.GrantRevoke; import org.h2.command.ddl.GrantRevoke;
import org.h2.command.ddl.PrepareProcedure; import org.h2.command.ddl.PrepareProcedure;
...@@ -137,6 +137,7 @@ import org.h2.constraint.ConstraintActionType; ...@@ -137,6 +137,7 @@ 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;
import org.h2.engine.Domain;
import org.h2.engine.FunctionAlias; import org.h2.engine.FunctionAlias;
import org.h2.engine.Mode; import org.h2.engine.Mode;
import org.h2.engine.Mode.ModeEnum; import org.h2.engine.Mode.ModeEnum;
...@@ -145,7 +146,6 @@ import org.h2.engine.Right; ...@@ -145,7 +146,6 @@ import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.User; import org.h2.engine.User;
import org.h2.engine.UserAggregate; import org.h2.engine.UserAggregate;
import org.h2.engine.UserDataType;
import org.h2.expression.Alias; import org.h2.expression.Alias;
import org.h2.expression.BinaryOperation; import org.h2.expression.BinaryOperation;
import org.h2.expression.BinaryOperation.OpType; import org.h2.expression.BinaryOperation.OpType;
...@@ -1940,7 +1940,7 @@ public class Parser { ...@@ -1940,7 +1940,7 @@ public class Parser {
} else if (readIf("USER")) { } else if (readIf("USER")) {
type = DbObject.USER; type = DbObject.USER;
} else if (readIf("DOMAIN")) { } else if (readIf("DOMAIN")) {
type = DbObject.USER_DATATYPE; type = DbObject.DOMAIN;
} else { } else {
throw getSyntaxError(); throw getSyntaxError();
} }
...@@ -2098,7 +2098,7 @@ public class Parser { ...@@ -2098,7 +2098,7 @@ public class Parser {
} }
return command; return command;
} else if (readIf("DOMAIN") || readIf("TYPE") || readIf("DATATYPE")) { } else if (readIf("DOMAIN") || readIf("TYPE") || readIf("DATATYPE")) {
return parseDropUserDataType(); return parseDropDomain();
} else if (readIf("AGGREGATE")) { } else if (readIf("AGGREGATE")) {
return parseDropAggregate(); return parseDropAggregate();
} else if (readIf("SYNONYM")) { } else if (readIf("SYNONYM")) {
...@@ -2113,9 +2113,9 @@ public class Parser { ...@@ -2113,9 +2113,9 @@ public class Parser {
throw getSyntaxError(); throw getSyntaxError();
} }
private DropUserDataType parseDropUserDataType() { private DropDomain parseDropDomain() {
boolean ifExists = readIfExists(false); boolean ifExists = readIfExists(false);
DropUserDataType command = new DropUserDataType(session); DropDomain command = new DropDomain(session);
command.setTypeName(readUniqueIdentifier()); command.setTypeName(readUniqueIdentifier());
ifExists = readIfExists(ifExists); ifExists = readIfExists(ifExists);
command.setIfExists(ifExists); command.setIfExists(ifExists);
...@@ -5122,12 +5122,12 @@ public class Parser { ...@@ -5122,12 +5122,12 @@ public class Parser {
if (!identifiersToUpper) { if (!identifiersToUpper) {
original = StringUtils.toUpperEnglish(original); original = StringUtils.toUpperEnglish(original);
} }
UserDataType userDataType = database.findUserDataType(original); Domain domain = database.findDomain(original);
if (userDataType != null) { if (domain != null) {
templateColumn = userDataType.getColumn(); templateColumn = domain.getColumn();
dataType = DataType.getDataType(templateColumn.getType()); dataType = DataType.getDataType(templateColumn.getType());
comment = templateColumn.getComment(); comment = templateColumn.getComment();
original = forTable ? userDataType.getSQL() : templateColumn.getOriginalSQL(); original = forTable ? domain.getSQL() : templateColumn.getOriginalSQL();
precision = templateColumn.getPrecision(); precision = templateColumn.getPrecision();
displaySize = templateColumn.getDisplaySize(); displaySize = templateColumn.getDisplaySize();
scale = templateColumn.getScale(); scale = templateColumn.getScale();
...@@ -5344,7 +5344,7 @@ public class Parser { ...@@ -5344,7 +5344,7 @@ public class Parser {
column.setComment(comment); column.setComment(comment);
column.setOriginalSQL(original); column.setOriginalSQL(original);
if (forTable) { if (forTable) {
column.setUserDataType(userDataType); column.setDomain(domain);
} }
return column; return column;
} }
...@@ -5373,7 +5373,7 @@ public class Parser { ...@@ -5373,7 +5373,7 @@ public class Parser {
} else if (readIf("CONSTANT")) { } else if (readIf("CONSTANT")) {
return parseCreateConstant(); return parseCreateConstant();
} else if (readIf("DOMAIN") || readIf("TYPE") || readIf("DATATYPE")) { } else if (readIf("DOMAIN") || readIf("TYPE") || readIf("DATATYPE")) {
return parseCreateUserDataType(); return parseCreateDomain();
} else if (readIf("AGGREGATE")) { } else if (readIf("AGGREGATE")) {
return parseCreateAggregate(force); return parseCreateAggregate(force);
} else if (readIf("LINKED")) { } else if (readIf("LINKED")) {
...@@ -5741,9 +5741,9 @@ public class Parser { ...@@ -5741,9 +5741,9 @@ public class Parser {
return command; return command;
} }
private CreateUserDataType parseCreateUserDataType() { private CreateDomain parseCreateDomain() {
boolean ifNotExists = readIfNotExists(); boolean ifNotExists = readIfNotExists();
CreateUserDataType command = new CreateUserDataType(session); CreateDomain command = new CreateDomain(session);
command.setTypeName(readUniqueIdentifier()); command.setTypeName(readUniqueIdentifier());
read("AS"); read("AS");
Column col = parseColumnForTable("VALUE", true, false); Column col = parseColumnForTable("VALUE", true, false);
......
...@@ -8,8 +8,8 @@ package org.h2.command.ddl; ...@@ -8,8 +8,8 @@ package org.h2.command.ddl;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Domain;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.UserDataType;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.table.Column; import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
...@@ -19,13 +19,13 @@ import org.h2.value.DataType; ...@@ -19,13 +19,13 @@ import org.h2.value.DataType;
* This class represents the statement * This class represents the statement
* CREATE DOMAIN * CREATE DOMAIN
*/ */
public class CreateUserDataType extends DefineCommand { public class CreateDomain extends DefineCommand {
private String typeName; private String typeName;
private Column column; private Column column;
private boolean ifNotExists; private boolean ifNotExists;
public CreateUserDataType(Session session) { public CreateDomain(Session session) {
super(session); super(session);
} }
...@@ -47,30 +47,30 @@ public class CreateUserDataType extends DefineCommand { ...@@ -47,30 +47,30 @@ public class CreateUserDataType extends DefineCommand {
session.commit(true); session.commit(true);
Database db = session.getDatabase(); Database db = session.getDatabase();
session.getUser().checkAdmin(); session.getUser().checkAdmin();
if (db.findUserDataType(typeName) != null) { if (db.findDomain(typeName) != null) {
if (ifNotExists) { if (ifNotExists) {
return 0; return 0;
} }
throw DbException.get( throw DbException.get(
ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1, ErrorCode.DOMAIN_ALREADY_EXISTS_1,
typeName); typeName);
} }
DataType builtIn = DataType.getTypeByName(typeName, session.getDatabase().getMode()); DataType builtIn = DataType.getTypeByName(typeName, session.getDatabase().getMode());
if (builtIn != null) { if (builtIn != null) {
if (!builtIn.hidden) { if (!builtIn.hidden) {
throw DbException.get( throw DbException.get(
ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1, ErrorCode.DOMAIN_ALREADY_EXISTS_1,
typeName); typeName);
} }
Table table = session.getDatabase().getFirstUserTable(); Table table = session.getDatabase().getFirstUserTable();
if (table != null) { if (table != null) {
throw DbException.get( throw DbException.get(
ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1, ErrorCode.DOMAIN_ALREADY_EXISTS_1,
typeName + " (" + table.getSQL() + ")"); typeName + " (" + table.getSQL() + ")");
} }
} }
int id = getObjectId(); int id = getObjectId();
UserDataType type = new UserDataType(db, id, typeName); Domain type = new Domain(db, id, typeName);
type.setColumn(column); type.setColumn(column);
db.addDatabaseObject(session, type); db.addDatabaseObject(session, type);
return 0; return 0;
......
...@@ -135,7 +135,7 @@ public class DropDatabase extends DefineCommand { ...@@ -135,7 +135,7 @@ public class DropDatabase extends DefineCommand {
ArrayList<DbObject> dbObjects = new ArrayList<>(); ArrayList<DbObject> dbObjects = new ArrayList<>();
dbObjects.addAll(db.getAllRights()); dbObjects.addAll(db.getAllRights());
dbObjects.addAll(db.getAllAggregates()); dbObjects.addAll(db.getAllAggregates());
dbObjects.addAll(db.getAllUserDataTypes()); dbObjects.addAll(db.getAllDomains());
for (DbObject obj : dbObjects) { for (DbObject obj : dbObjects) {
String sql = obj.getCreateSQL(); String sql = obj.getCreateSQL();
// the role PUBLIC must not be dropped // the role PUBLIC must not be dropped
......
...@@ -9,8 +9,8 @@ import org.h2.api.ErrorCode; ...@@ -9,8 +9,8 @@ import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.constraint.ConstraintActionType; import org.h2.constraint.ConstraintActionType;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Domain;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.UserDataType;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.table.Column; import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
...@@ -19,13 +19,13 @@ import org.h2.table.Table; ...@@ -19,13 +19,13 @@ import org.h2.table.Table;
* This class represents the statement * This class represents the statement
* DROP DOMAIN * DROP DOMAIN
*/ */
public class DropUserDataType extends DefineCommand { public class DropDomain extends DefineCommand {
private String typeName; private String typeName;
private boolean ifExists; private boolean ifExists;
private ConstraintActionType dropAction; private ConstraintActionType dropAction;
public DropUserDataType(Session session) { public DropDomain(Session session) {
super(session); super(session);
dropAction = session.getDatabase().getSettings().dropRestrict ? dropAction = session.getDatabase().getSettings().dropRestrict ?
ConstraintActionType.RESTRICT : ConstraintActionType.CASCADE; ConstraintActionType.RESTRICT : ConstraintActionType.CASCADE;
...@@ -44,22 +44,22 @@ public class DropUserDataType extends DefineCommand { ...@@ -44,22 +44,22 @@ public class DropUserDataType extends DefineCommand {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
session.commit(true); session.commit(true);
Database db = session.getDatabase(); Database db = session.getDatabase();
UserDataType type = db.findUserDataType(typeName); Domain type = db.findDomain(typeName);
if (type == null) { if (type == null) {
if (!ifExists) { if (!ifExists) {
throw DbException.get(ErrorCode.USER_DATA_TYPE_NOT_FOUND_1, typeName); throw DbException.get(ErrorCode.DOMAIN_NOT_FOUND_1, typeName);
} }
} else { } else {
for (Table t : db.getAllTablesAndViews(false)) { for (Table t : db.getAllTablesAndViews(false)) {
boolean modified = false; boolean modified = false;
for (Column c : t.getColumns()) { for (Column c : t.getColumns()) {
UserDataType udt = c.getUserDataType(); Domain domain = c.getDomain();
if (udt != null && udt.getName().equals(typeName)) { if (domain != null && domain.getName().equals(typeName)) {
if (dropAction == ConstraintActionType.RESTRICT) { if (dropAction == ConstraintActionType.RESTRICT) {
throw DbException.get(ErrorCode.CANNOT_DROP_2, typeName, t.getCreateSQL()); throw DbException.get(ErrorCode.CANNOT_DROP_2, typeName, t.getCreateSQL());
} }
c.setOriginalSQL(type.getColumn().getOriginalSQL()); c.setOriginalSQL(type.getColumn().getOriginalSQL());
c.setUserDataType(null); c.setDomain(null);
modified = true; modified = true;
} }
} }
......
...@@ -80,10 +80,10 @@ public class SetComment extends DefineCommand { ...@@ -80,10 +80,10 @@ public class SetComment extends DefineCommand {
schemaName = null; schemaName = null;
object = db.getUser(objectName); object = db.getUser(objectName);
break; break;
case DbObject.USER_DATATYPE: case DbObject.DOMAIN:
schemaName = null; schemaName = null;
object = db.findUserDataType(objectName); object = db.findDomain(objectName);
errorCode = ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1; errorCode = ErrorCode.DOMAIN_ALREADY_EXISTS_1;
break; break;
default: default:
} }
......
...@@ -29,6 +29,7 @@ import org.h2.engine.Comment; ...@@ -29,6 +29,7 @@ import org.h2.engine.Comment;
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;
import org.h2.engine.Domain;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Role; import org.h2.engine.Role;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -36,7 +37,6 @@ import org.h2.engine.Setting; ...@@ -36,7 +37,6 @@ import org.h2.engine.Setting;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.engine.User; import org.h2.engine.User;
import org.h2.engine.UserAggregate; import org.h2.engine.UserAggregate;
import org.h2.engine.UserDataType;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.index.Cursor; import org.h2.index.Cursor;
...@@ -187,7 +187,7 @@ public class ScriptCommand extends ScriptBase { ...@@ -187,7 +187,7 @@ public class ScriptCommand extends ScriptBase {
} }
add(schema.getCreateSQL(), false); add(schema.getCreateSQL(), false);
} }
for (UserDataType datatype : db.getAllUserDataTypes()) { for (Domain datatype : db.getAllDomains()) {
if (drop) { if (drop) {
add(datatype.getDropSQL(), false); add(datatype.getDropSQL(), false);
} }
......
...@@ -52,7 +52,7 @@ public class Comment extends DbObjectBase { ...@@ -52,7 +52,7 @@ public class Comment extends DbObjectBase {
return "TRIGGER"; return "TRIGGER";
case DbObject.USER: case DbObject.USER:
return "USER"; return "USER";
case DbObject.USER_DATATYPE: case DbObject.DOMAIN:
return "DOMAIN"; return "DOMAIN";
default: default:
// not supported by parser, but required when trying to find a // not supported by parser, but required when trying to find a
......
...@@ -140,7 +140,7 @@ public class Database implements DataHandler { ...@@ -140,7 +140,7 @@ public class Database implements DataHandler {
private final HashMap<String, Setting> settings = new HashMap<>(); private final HashMap<String, Setting> settings = new HashMap<>();
private final HashMap<String, Schema> schemas = new HashMap<>(); private final HashMap<String, Schema> schemas = new HashMap<>();
private final HashMap<String, Right> rights = new HashMap<>(); private final HashMap<String, Right> rights = new HashMap<>();
private final HashMap<String, UserDataType> userDataTypes = new HashMap<>(); private final HashMap<String, Domain> domains = new HashMap<>();
private final HashMap<String, UserAggregate> aggregates = new HashMap<>(); private final HashMap<String, UserAggregate> aggregates = new HashMap<>();
private final HashMap<String, Comment> comments = new HashMap<>(); private final HashMap<String, Comment> comments = new HashMap<>();
private final HashMap<String, TableEngine> tableEngines = new HashMap<>(); private final HashMap<String, TableEngine> tableEngines = new HashMap<>();
...@@ -1135,8 +1135,8 @@ public class Database implements DataHandler { ...@@ -1135,8 +1135,8 @@ public class Database implements DataHandler {
case DbObject.SCHEMA: case DbObject.SCHEMA:
result = schemas; result = schemas;
break; break;
case DbObject.USER_DATATYPE: case DbObject.DOMAIN:
result = userDataTypes; result = domains;
break; break;
case DbObject.COMMENT: case DbObject.COMMENT:
result = comments; result = comments;
...@@ -1265,13 +1265,13 @@ public class Database implements DataHandler { ...@@ -1265,13 +1265,13 @@ public class Database implements DataHandler {
} }
/** /**
* Get the user defined data type if it exists, or null if not. * Get the domain if it exists, or null if not.
* *
* @param name the name of the user defined data type * @param name the name of the domain
* @return the user defined data type or null * @return the domain or null
*/ */
public UserDataType findUserDataType(String name) { public Domain findDomain(String name) {
return userDataTypes.get(name); return domains.get(name);
} }
/** /**
...@@ -1743,8 +1743,8 @@ public class Database implements DataHandler { ...@@ -1743,8 +1743,8 @@ public class Database implements DataHandler {
return new ArrayList<>(settings.values()); return new ArrayList<>(settings.values());
} }
public ArrayList<UserDataType> getAllUserDataTypes() { public ArrayList<Domain> getAllDomains() {
return new ArrayList<>(userDataTypes.values()); return new ArrayList<>(domains.values());
} }
public ArrayList<User> getAllUsers() { public ArrayList<User> getAllUsers() {
......
...@@ -75,9 +75,9 @@ public interface DbObject { ...@@ -75,9 +75,9 @@ public interface DbObject {
int CONSTANT = 11; int CONSTANT = 11;
/** /**
* This object is a user data type (domain). * This object is a domain.
*/ */
int USER_DATATYPE = 12; int DOMAIN = 12;
/** /**
* This object is a comment. * This object is a comment.
......
...@@ -11,13 +11,13 @@ import org.h2.table.Column; ...@@ -11,13 +11,13 @@ import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* Represents a domain (user-defined data type). * Represents a domain.
*/ */
public class UserDataType extends DbObjectBase { public class Domain extends DbObjectBase {
private Column column; private Column column;
public UserDataType(Database database, int id, String name) { public Domain(Database database, int id, String name) {
super(database, id, name, Trace.DATABASE); super(database, id, name, Trace.DATABASE);
} }
...@@ -42,7 +42,7 @@ public class UserDataType extends DbObjectBase { ...@@ -42,7 +42,7 @@ public class UserDataType extends DbObjectBase {
@Override @Override
public int getType() { public int getType() {
return DbObject.USER_DATATYPE; return DbObject.DOMAIN;
} }
@Override @Override
......
...@@ -115,7 +115,7 @@ public class MetaRecord implements Comparable<MetaRecord> { ...@@ -115,7 +115,7 @@ public class MetaRecord implements Comparable<MetaRecord> {
return 2; return 2;
case DbObject.FUNCTION_ALIAS: case DbObject.FUNCTION_ALIAS:
return 3; return 3;
case DbObject.USER_DATATYPE: case DbObject.DOMAIN:
return 4; return 4;
case DbObject.SEQUENCE: case DbObject.SEQUENCE:
return 5; return 5;
......
...@@ -556,8 +556,8 @@ public class DbException extends RuntimeException { ...@@ -556,8 +556,8 @@ public class DbException extends RuntimeException {
case CONSTANT_NOT_FOUND_1: case CONSTANT_NOT_FOUND_1:
case LITERALS_ARE_NOT_ALLOWED: case LITERALS_ARE_NOT_ALLOWED:
case CANNOT_DROP_TABLE_1: case CANNOT_DROP_TABLE_1:
case USER_DATA_TYPE_ALREADY_EXISTS_1: case DOMAIN_ALREADY_EXISTS_1:
case USER_DATA_TYPE_NOT_FOUND_1: case DOMAIN_NOT_FOUND_1:
case WITH_TIES_WITHOUT_ORDER_BY: case WITH_TIES_WITHOUT_ORDER_BY:
case CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS: case CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS:
case TRANSACTION_NOT_FOUND_1: case TRANSACTION_NOT_FOUND_1:
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Definice tohoto druhu nejsou povoleny 90116=Definice tohoto druhu nejsou povoleny
90117=Vzdálené připojení není na tomto serveru povoleno, zkontrolujte volbu -tcpAllowOthers 90117=Vzdálené připojení není na tomto serveru povoleno, zkontrolujte volbu -tcpAllowOthers
90118=Nelze odstranit tabulku {0} 90118=Nelze odstranit tabulku {0}
90119=Uživatelský datový typ {0} již existuje 90119=Doména {0} již existuje
90120=Uživatelský datový typ {0} nenalezen 90120=Doména {0} nenalezen
90121=Databáze byla již ukončena (pro deaktivaci automatického ukončení při zastavení virtuálního stroje přidejte parametr ";DB_CLOSE_ON_EXIT=FALSE" do URL databáze) 90121=Databáze byla již ukončena (pro deaktivaci automatického ukončení při zastavení virtuálního stroje přidejte parametr ";DB_CLOSE_ON_EXIT=FALSE" do URL databáze)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Nelze vzájemně míchat indexované a neindexované parametry 90123=Nelze vzájemně míchat indexované a neindexované parametry
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Literal dieser Art nicht zugelassen 90116=Literal dieser Art nicht zugelassen
90117=Verbindungen von anderen Rechnern sind nicht freigegeben, siehe -tcpAllowOthers 90117=Verbindungen von anderen Rechnern sind nicht freigegeben, siehe -tcpAllowOthers
90118=Kann Tabelle nicht löschen {0} 90118=Kann Tabelle nicht löschen {0}
90119=Benutzer-Datentyp {0} besteht bereits 90119=Domäne {0} besteht bereits
90120=Benutzer-Datentyp {0} nicht gefunden 90120=Domäne {0} nicht gefunden
90121=Die Datenbank wurde bereits geschlossen (um das automatische Schliessen beim Stopp der VM zu deaktivieren, die Datenbank URL mit ";DB_CLOSE_ON_EXIT=FALSE" ergänzen) 90121=Die Datenbank wurde bereits geschlossen (um das automatische Schliessen beim Stopp der VM zu deaktivieren, die Datenbank URL mit ";DB_CLOSE_ON_EXIT=FALSE" ergänzen)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Kann nicht indizierte und nicht indizierte Parameter mischen 90123=Kann nicht indizierte und nicht indizierte Parameter mischen
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Literals of this kind are not allowed 90116=Literals of this kind are not allowed
90117=Remote connections to this server are not allowed, see -tcpAllowOthers 90117=Remote connections to this server are not allowed, see -tcpAllowOthers
90118=Cannot drop table {0} 90118=Cannot drop table {0}
90119=User data type {0} already exists 90119=Domain {0} already exists
90120=User data type {0} not found 90120=Domain {0} not found
90121=Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) 90121=Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL)
90122=The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Cannot mix indexed and non-indexed parameters 90123=Cannot mix indexed and non-indexed parameters
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Literales de este tipo no estan permitidos 90116=Literales de este tipo no estan permitidos
90117=Este server no permite Conexiones Remotas, vea -tcpAllowOthers 90117=Este server no permite Conexiones Remotas, vea -tcpAllowOthers
90118=Imposible eliminar tabla {0} 90118=Imposible eliminar tabla {0}
90119=Tipo de dato de usuario {0} ya existe 90119=Dominio {0} ya existe
90120=Tipo de dato de usuario {0} no encontrado 90120=Dominio {0} no encontrado
90121=La base de datos ya esta cerrada (para des-habilitar el cerrado automatico durante el shutdown de la VM, agregue ";DB_CLOSE_ON_EXIT=FALSE" a la URL de conexión) 90121=La base de datos ya esta cerrada (para des-habilitar el cerrado automatico durante el shutdown de la VM, agregue ";DB_CLOSE_ON_EXIT=FALSE" a la URL de conexión)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=No se puede mezclar parametros indexados y no-indexados 90123=No se puede mezclar parametros indexados y no-indexados
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Les littérals de ce type ne sont pas permis 90116=Les littérals de ce type ne sont pas permis
90117=Les connexions à distance à ce serveur ne sont pas autorisées, voir -tcpAllowOthers 90117=Les connexions à distance à ce serveur ne sont pas autorisées, voir -tcpAllowOthers
90118=Impossible de supprimer la table {0} 90118=Impossible de supprimer la table {0}
90119=Le type de données utilisateur {0} existe déjà 90119=Le domaine {0} existe déjà
90120=Type de données utilisateur {0} non trouvé 90120=Le domaine {0} non trouvé
90121=La base de données est déjà fermée (pour désactiver la fermeture automatique à l''arrêt de la VM, ajoutez "; DB_CLOSE_ON_EXIT = FALSE" à l''URL db) 90121=La base de données est déjà fermée (pour désactiver la fermeture automatique à l''arrêt de la VM, ajoutez "; DB_CLOSE_ON_EXIT = FALSE" à l''URL db)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Impossible de mélanger des paramètres indexés et non-indexés 90123=Impossible de mélanger des paramètres indexés et non-indexés
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=この種類のリテラルは許されていません 90116=この種類のリテラルは許されていません
90117=このサーバへのリモート接続は許されていません, -tcpAllowOthersを参照 90117=このサーバへのリモート接続は許されていません, -tcpAllowOthersを参照
90118=テーブル {0} はドロップできません 90118=テーブル {0} はドロップできません
90119=ユーザデータ型 {0} はすでに存在します 90119=ドメイン {0} はすでに存在します
90120=ユーザデータ型 {0} が見つかりません 90120=ドメイン {0} が見つかりません
90121=データベースはすでに閉じられています (VM終了時の自動データベースクローズを無効にするためには、db URLに ";DB_CLOSE_ON_EXIT=FALSE" を追加してください) 90121=データベースはすでに閉じられています (VM終了時の自動データベースクローズを無効にするためには、db URLに ";DB_CLOSE_ON_EXIT=FALSE" を追加してください)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=インデックスの付いたパラメータと付いていないパラメータを混在させることはできません 90123=インデックスの付いたパラメータと付いていないパラメータを混在させることはできません
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Literał tego typu nie jest dozwolony 90116=Literał tego typu nie jest dozwolony
90117=Zdalne połączenia do tego serwera nie są dozwolone, zobacz -tcpAllowOthers 90117=Zdalne połączenia do tego serwera nie są dozwolone, zobacz -tcpAllowOthers
90118=Nie można skasować tabeli {0} 90118=Nie można skasować tabeli {0}
90119=Typ danych użytkownika {0} już istnieje 90119=Domena {0} już istnieje
90120=Typ danych użytkownika {0} nie istnieje 90120=Domena {0} nie istnieje
90121=Baza danych jest już zamknięta (aby zablokować samoczynne zamykanie podczas zamknięcia VM dodaj ";DB_CLOSE_ON_EXIT=FALSE" do URL bazy danych) 90121=Baza danych jest już zamknięta (aby zablokować samoczynne zamykanie podczas zamknięcia VM dodaj ";DB_CLOSE_ON_EXIT=FALSE" do URL bazy danych)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Nie można mieszać parametrów indeksowych z nieindeksowymi 90123=Nie można mieszać parametrów indeksowych z nieindeksowymi
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Literais deste tipo não são permitidas 90116=Literais deste tipo não são permitidas
90117=Conecções remotas para este servidor não estão habilitadas, veja -tcpAllowOthers 90117=Conecções remotas para este servidor não estão habilitadas, veja -tcpAllowOthers
90118=Não pode apagar a tabela {0} 90118=Não pode apagar a tabela {0}
90119=Tipo de dados do usuário {0} já existe 90119=Domínio {0} já existe
90120=Tipo de dados do usuário {0} não foram encontrados 90120=Domínio {0} não foram encontrados
90121=Base de dados já está fechada (para desabilitar o fechamento automático quando a VM terminar, addicione ";DB_CLOSE_ON_EXIT=FALSE" na url da base de dados) 90121=Base de dados já está fechada (para desabilitar o fechamento automático quando a VM terminar, addicione ";DB_CLOSE_ON_EXIT=FALSE" na url da base de dados)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Não pode combinar parâmetros de índices com não índices 90123=Não pode combinar parâmetros de índices com não índices
......
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
90116=Вычисление литералов запрещено 90116=Вычисление литералов запрещено
90117=Удаленные соединения к данному серверу запрещены, см. -tcpAllowOthers 90117=Удаленные соединения к данному серверу запрещены, см. -tcpAllowOthers
90118=Невозможно удалить таблицу {0} 90118=Невозможно удалить таблицу {0}
90119=Объект с именем {0} уже существует 90119=Домен {0} уже существует
90120=Домен {0} не найден 90120=Домен {0} не найден
90121=База данных уже закрыта (чтобы отключить автоматическое закрытие базы данных при останове JVM, добавьте ";DB_CLOSE_ON_EXIT=FALSE" в URL) 90121=База данных уже закрыта (чтобы отключить автоматическое закрытие базы данных при останове JVM, добавьте ";DB_CLOSE_ON_EXIT=FALSE" в URL)
90122=Ограничение WITH TIES использовано без соответствующего раздела ORDER BY. 90122=Ограничение WITH TIES использовано без соответствующего раздела ORDER BY.
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=Písmená (literals) tohto druhu nie sú povolené 90116=Písmená (literals) tohto druhu nie sú povolené
90117=Vzdialené pripojenia na tento server nie sú povolené, pozrite -tcpAllowOthers 90117=Vzdialené pripojenia na tento server nie sú povolené, pozrite -tcpAllowOthers
90118=Nemôžem zmazať tabuľku {0} 90118=Nemôžem zmazať tabuľku {0}
90119=Používateľský dátový typ {0} už existuje 90119=Doména {0} už existuje
90120=Používateľský dátový typ {0} nenájdený 90120=Doména {0} nenájdený
90121=Databáza už je zatvorená (na zamedzenie automatického zatvárania pri ukončení VM, pridajte ";DB_CLOSE_ON_EXIT=FALSE" do DB URL) 90121=Databáza už je zatvorená (na zamedzenie automatického zatvárania pri ukončení VM, pridajte ";DB_CLOSE_ON_EXIT=FALSE" do DB URL)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=Nemožno miešať indexované a neindexované parametre 90123=Nemožno miešať indexované a neindexované parametre
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
90116=不允许此类型的字面值 90116=不允许此类型的字面值
90117=不允许远程连接到本服务器, 参见 -tcpAllowOthers 90117=不允许远程连接到本服务器, 参见 -tcpAllowOthers
90118=不能删除表 {0} 90118=不能删除表 {0}
90119=用户数据类型 {0} 已存在 90119= {0} 已存在
90120=找不到用户数据类型 {0} 90120=找不到 {0}
90121=数据库已关闭 (若需要禁用在虚拟机关闭的时候同时关闭数据库,请加上 ";DB_CLOSE_ON_EXIT=FALSE" 到数据库连接的 URL) 90121=数据库已关闭 (若需要禁用在虚拟机关闭的时候同时关闭数据库,请加上 ";DB_CLOSE_ON_EXIT=FALSE" 到数据库连接的 URL)
90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause. 90122=#The WITH TIES clause is not allowed without a corresponding ORDER BY clause.
90123=不能混合已索引和未索引的参数 90123=不能混合已索引和未索引的参数
......
...@@ -12,9 +12,9 @@ import org.h2.api.ErrorCode; ...@@ -12,9 +12,9 @@ import org.h2.api.ErrorCode;
import org.h2.command.Parser; import org.h2.command.Parser;
import org.h2.command.ddl.SequenceOptions; import org.h2.command.ddl.SequenceOptions;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Domain;
import org.h2.engine.Mode; import org.h2.engine.Mode;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.UserDataType;
import org.h2.expression.ConditionAndOr; import org.h2.expression.ConditionAndOr;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionVisitor; import org.h2.expression.ExpressionVisitor;
...@@ -88,7 +88,7 @@ public class Column { ...@@ -88,7 +88,7 @@ public class Column {
private String comment; private String comment;
private boolean primaryKey; private boolean primaryKey;
private boolean visible = true; private boolean visible = true;
private UserDataType userDataType; private Domain domain;
public Column(String name, int type) { public Column(String name, int type) {
this(name, type, -1, -1, -1, null); this(name, type, -1, -1, -1, null);
...@@ -311,12 +311,12 @@ public class Column { ...@@ -311,12 +311,12 @@ public class Column {
visible = b; visible = b;
} }
public UserDataType getUserDataType() { public Domain getDomain() {
return userDataType; return domain;
} }
public void setUserDataType(UserDataType userDataType) { public void setDomain(Domain domain) {
this.userDataType = userDataType; this.domain = domain;
} }
/** /**
...@@ -563,7 +563,7 @@ public class Column { ...@@ -563,7 +563,7 @@ public class Column {
} }
if (!nullable) { if (!nullable) {
buff.append(" NOT NULL"); buff.append(" NOT NULL");
} else if (userDataType != null && !userDataType.getColumn().isNullable()) { } else if (domain != null && !domain.getColumn().isNullable()) {
buff.append(" NULL"); buff.append(" NULL");
} }
if (convertNullToDefault) { if (convertNullToDefault) {
......
...@@ -27,6 +27,7 @@ import org.h2.constraint.ConstraintUnique; ...@@ -27,6 +27,7 @@ import org.h2.constraint.ConstraintUnique;
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;
import org.h2.engine.Domain;
import org.h2.engine.FunctionAlias; import org.h2.engine.FunctionAlias;
import org.h2.engine.FunctionAlias.JavaMethod; import org.h2.engine.FunctionAlias.JavaMethod;
import org.h2.engine.QueryStatisticsData; import org.h2.engine.QueryStatisticsData;
...@@ -36,7 +37,6 @@ import org.h2.engine.Session; ...@@ -36,7 +37,6 @@ import org.h2.engine.Session;
import org.h2.engine.Setting; import org.h2.engine.Setting;
import org.h2.engine.User; import org.h2.engine.User;
import org.h2.engine.UserAggregate; import org.h2.engine.UserAggregate;
import org.h2.engine.UserDataType;
import org.h2.expression.ValueExpression; import org.h2.expression.ValueExpression;
import org.h2.index.Index; import org.h2.index.Index;
import org.h2.index.IndexType; import org.h2.index.IndexType;
...@@ -846,7 +846,7 @@ public class MetaTable extends Table { ...@@ -846,7 +846,7 @@ public class MetaTable extends Table {
String collation = database.getCompareMode().getName(); String collation = database.getCompareMode().getName();
for (int j = 0; j < cols.length; j++) { for (int j = 0; j < cols.length; j++) {
Column c = cols[j]; Column c = cols[j];
UserDataType domain = c.getUserDataType(); Domain domain = c.getDomain();
DataType dataType = c.getDataType(); DataType dataType = c.getDataType();
ValueInt precision = ValueInt.get(c.getPrecisionAsInt()); ValueInt precision = ValueInt.get(c.getPrecisionAsInt());
ValueInt scale = ValueInt.get(c.getScale()); ValueInt scale = ValueInt.get(c.getScale());
...@@ -1774,7 +1774,7 @@ public class MetaTable extends Table { ...@@ -1774,7 +1774,7 @@ public class MetaTable extends Table {
break; break;
} }
case DOMAINS: { case DOMAINS: {
for (UserDataType dt : database.getAllUserDataTypes()) { for (Domain dt : database.getAllDomains()) {
Column col = dt.getColumn(); Column col = dt.getColumn();
add(rows, add(rows,
// DOMAIN_CATALOG // DOMAIN_CATALOG
......
...@@ -119,7 +119,7 @@ public class TestCompatibility extends TestDb { ...@@ -119,7 +119,7 @@ public class TestCompatibility extends TestDb {
} }
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key) as select 1"); stat.execute("create table test(id int primary key) as select 1");
assertThrows(ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1, stat). assertThrows(ErrorCode.DOMAIN_ALREADY_EXISTS_1, stat).
execute("create domain int as varchar"); execute("create domain int as varchar");
conn.close(); conn.close();
conn = getConnection("compatibility"); conn = getConnection("compatibility");
......
...@@ -757,7 +757,7 @@ drop table parent, child; ...@@ -757,7 +757,7 @@ drop table parent, child;
> ok > ok
create domain integer as varchar; create domain integer as varchar;
> exception USER_DATA_TYPE_ALREADY_EXISTS_1 > exception DOMAIN_ALREADY_EXISTS_1
create domain int as varchar; create domain int as varchar;
> ok > ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论