Unverified 提交 975a9d76 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1509 from katzyn/domain

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