if (typeNumber == Integer.MIN_VALUE) {
if (includeUserTypes) {
checkIsSchemaObjectName();
String schemaName = session.getSchemaName(token.namePrefix);
Type type = database.schemaManager.getDomain(token.tokenString,
schemaName, false);
if (type != null) {
read();
return type;
}
}
throw Error.error(ErrorCode.X_42509, token.tokenString);
}
read();
switch (typeNumber) {
case Types.SQL_CHAR :
if (token.tokenType == Tokens.VARYING) {
read();
typeNumber = Types.SQL_VARCHAR;
} else if (token.tokenType == Tokens.LARGE) {
readThis(Tokens.OBJECT);
read();
typeNumber = Types.SQL_CLOB;
}
break;
case Types.SQL_DOUBLE :
if (token.tokenType == Tokens.PRECISION) {
read();
}
break;
case Types.SQL_BINARY :
if (token.tokenType == Tokens.VARYING) {
read();
typeNumber = Types.SQL_VARBINARY;
} else if (token.tokenType == Tokens.LARGE) {
readThis(Tokens.OBJECT);
read();
typeNumber = Types.SQL_BLOB;
}
break;
case Types.SQL_BIT :
if (token.tokenType == Tokens.VARYING) {
read();
typeNumber = Types.SQL_BIT_VARYING;
}
break;
case Types.SQL_INTERVAL :
return readIntervalType();
default :
}
long length = typeNumber == Types.SQL_TIMESTAMP
? DTIType.defaultTimestampFractionPrecision
: 0;
int scale = 0;
if (Types.requiresPrecision(typeNumber)
&& token.tokenType != Tokens.OPENBRACKET
&& database.sqlEnforceStrictSize) {
throw unexpectedTokenRequire(Tokens.T_OPENBRACKET);
}
// A VoltDB extension to support the character in bytes.
boolean inBytes = false;
// End of VoltDB extension
if (Types.acceptsPrecision(typeNumber)) {
if (token.tokenType == Tokens.OPENBRACKET) {
int multiplier = 1;
read();
switch (token.tokenType) {
case Tokens.X_VALUE :
if (token.dataType.typeCode != Types.SQL_INTEGER
&& token.dataType.typeCode
!= Types.SQL_BIGINT) {
throw unexpectedToken();
}
break;
case Tokens.X_LOB_SIZE :
if (typeNumber == Types.SQL_BLOB
|| typeNumber == Types.SQL_CLOB) {
switch (token.lobMultiplierType) {
case Tokens.K :
multiplier = 1024;
break;
case Tokens.M :
multiplier = 1024 * 1024;
break;
case Tokens.G :
multiplier = 1024 * 1024 * 1024;
break;
case Tokens.P :
case Tokens.T :
default :
throw unexpectedToken();
}
break;
} else {
throw unexpectedToken(token.getFullString());
}
default :
throw unexpectedToken();
}
length = ((Number) token.tokenValue).longValue();
if (length < 0
|| (length == 0
&& !Types.acceptsZeroPrecision(typeNumber))) {
throw Error.error(ErrorCode.X_42592);
}
length *= multiplier;
read();
if (typeNumber == Types.SQL_CHAR
|| typeNumber == Types.SQL_VARCHAR
|| typeNumber == Types.SQL_CLOB) {
if (token.tokenType == Tokens.CHARACTERS) {
read();
} else if (token.tokenType == Tokens.OCTETS) {
read();
length /= 2;
}
}
if (Types.acceptsScaleCreateParam(typeNumber)
&& token.tokenType == Tokens.COMMA) {
read();
scale = readInteger();
if (scale < 0) {
throw Error.error(ErrorCode.X_42592);
}
}
// A VoltDB extension to support the character in bytes.
if (typeNumber == Types.SQL_VARCHAR) {
inBytes = readIfThis(Tokens.BYTES);
}
// End of VoltDB extension
readThis(Tokens.CLOSEBRACKET);
} else if (typeNumber == Types.SQL_BIT) {
length = 1;
} else if (typeNumber == Types.SQL_BLOB
|| typeNumber == Types.SQL_CLOB) {
length = BlobType.defaultBlobSize;
} else if (database.sqlEnforceStrictSize) {
// BIT is always BIT(1), regardless of sqlEnforceStringSize
if (typeNumber == Types.SQL_CHAR
|| typeNumber == Types.SQL_BINARY) {
length = 1;
}
}
if (typeNumber == Types.SQL_TIMESTAMP
|| typeNumber == Types.SQL_TIME) {
if (length > DTIType.maxFractionPrecision) {
throw Error.error(ErrorCode.X_42592);
}
scale = (int) length;
length = 0;
if (token.tokenType == Tokens.WITH) {
read();
readThis(Tokens.TIME);
readThis(Tokens.ZONE);
if (typeNumber == Types.SQL_TIMESTAMP) {
typeNumber = Types.SQL_TIMESTAMP_WITH_TIME_ZONE;
} else {
typeNumber = Types.SQL_TIME_WITH_TIME_ZONE;
}
} else if (token.tokenType == Tokens.WITHOUT) {
read();
readThis(Tokens.TIME);
readThis(Tokens.ZONE);
}
}
}
Type typeObject = Type.getType(typeNumber, 0, length, scale);
if (typeObject.isCharacterType()) {
// A VoltDB extension to support the character in bytes.
if (inBytes) {
((CharacterType) typeObject).inBytes = true;
}
// End of VoltDB extension