Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bf368749
提交
bf368749
authored
2月 03, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use own method to create numeric DataType instances without parameters
上级
db870a95
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
37 行增加
和
43 行删除
+37
-43
Mode.java
h2/src/main/org/h2/engine/Mode.java
+3
-3
DataType.java
h2/src/main/org/h2/value/DataType.java
+34
-40
没有找到文件。
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
bf368749
...
@@ -279,12 +279,12 @@ public class Mode {
...
@@ -279,12 +279,12 @@ public class Mode {
// MS SQL Server does not support client info properties. See
// MS SQL Server does not support client info properties. See
// https://msdn.microsoft.com/en-Us/library/dd571296%28v=sql.110%29.aspx
// https://msdn.microsoft.com/en-Us/library/dd571296%28v=sql.110%29.aspx
mode
.
supportedClientInfoPropertiesRegEx
=
null
;
mode
.
supportedClientInfoPropertiesRegEx
=
null
;
DataType
dt
=
DataType
.
create
Decimal
(
19
,
19
,
4
,
false
,
false
);
DataType
dt
=
DataType
.
create
Numeric
(
19
,
4
,
false
);
dt
.
type
=
Value
.
DECIMAL
;
dt
.
type
=
Value
.
DECIMAL
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
name
=
"MONEY"
;
dt
.
name
=
"MONEY"
;
mode
.
typeByNameMap
.
put
(
"MONEY"
,
dt
);
mode
.
typeByNameMap
.
put
(
"MONEY"
,
dt
);
dt
=
DataType
.
create
Decimal
(
10
,
10
,
4
,
false
,
false
);
dt
=
DataType
.
create
Numeric
(
10
,
4
,
false
);
dt
.
type
=
Value
.
DECIMAL
;
dt
.
type
=
Value
.
DECIMAL
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
name
=
"SMALLMONEY"
;
dt
.
name
=
"SMALLMONEY"
;
...
@@ -348,7 +348,7 @@ public class Mode {
...
@@ -348,7 +348,7 @@ public class Mode {
disallowedTypes
.
add
(
"TINYINT"
);
disallowedTypes
.
add
(
"TINYINT"
);
disallowedTypes
.
add
(
"BLOB"
);
disallowedTypes
.
add
(
"BLOB"
);
mode
.
disallowedTypes
=
disallowedTypes
;
mode
.
disallowedTypes
=
disallowedTypes
;
dt
=
DataType
.
create
Decimal
(
19
,
19
,
2
,
false
,
false
);
dt
=
DataType
.
create
Numeric
(
19
,
2
,
false
);
dt
.
type
=
Value
.
DECIMAL
;
dt
.
type
=
Value
.
DECIMAL
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
sqlType
=
Types
.
NUMERIC
;
dt
.
name
=
"MONEY"
;
dt
.
name
=
"MONEY"
;
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
bf368749
...
@@ -197,38 +197,31 @@ public class DataType {
...
@@ -197,38 +197,31 @@ public class DataType {
new
String
[]{
"VARCHAR_IGNORECASE"
}
new
String
[]{
"VARCHAR_IGNORECASE"
}
);
);
add
(
Value
.
BOOLEAN
,
Types
.
BOOLEAN
,
add
(
Value
.
BOOLEAN
,
Types
.
BOOLEAN
,
createDecimal
(
ValueBoolean
.
PRECISION
,
ValueBoolean
.
PRECISION
,
createNumeric
(
ValueBoolean
.
PRECISION
,
0
,
false
),
0
,
false
,
false
),
new
String
[]{
"BOOLEAN"
,
"BIT"
,
"BOOL"
}
new
String
[]{
"BOOLEAN"
,
"BIT"
,
"BOOL"
}
);
);
add
(
Value
.
BYTE
,
Types
.
TINYINT
,
add
(
Value
.
BYTE
,
Types
.
TINYINT
,
createDecimal
(
ValueByte
.
PRECISION
,
ValueByte
.
PRECISION
,
0
,
createNumeric
(
ValueByte
.
PRECISION
,
0
,
false
),
false
,
false
),
new
String
[]{
"TINYINT"
}
new
String
[]{
"TINYINT"
}
);
);
add
(
Value
.
SHORT
,
Types
.
SMALLINT
,
add
(
Value
.
SHORT
,
Types
.
SMALLINT
,
createDecimal
(
ValueShort
.
PRECISION
,
ValueShort
.
PRECISION
,
0
,
createNumeric
(
ValueShort
.
PRECISION
,
0
,
false
),
false
,
false
),
new
String
[]{
"SMALLINT"
,
"YEAR"
,
"INT2"
}
new
String
[]{
"SMALLINT"
,
"YEAR"
,
"INT2"
}
);
);
add
(
Value
.
INT
,
Types
.
INTEGER
,
add
(
Value
.
INT
,
Types
.
INTEGER
,
createDecimal
(
ValueInt
.
PRECISION
,
ValueInt
.
PRECISION
,
0
,
createNumeric
(
ValueInt
.
PRECISION
,
0
,
false
),
false
,
false
),
new
String
[]{
"INTEGER"
,
"INT"
,
"MEDIUMINT"
,
"INT4"
,
"SIGNED"
}
new
String
[]{
"INTEGER"
,
"INT"
,
"MEDIUMINT"
,
"INT4"
,
"SIGNED"
}
);
);
add
(
Value
.
INT
,
Types
.
INTEGER
,
add
(
Value
.
INT
,
Types
.
INTEGER
,
createDecimal
(
ValueInt
.
PRECISION
,
ValueInt
.
PRECISION
,
0
,
createNumeric
(
ValueInt
.
PRECISION
,
0
,
true
),
false
,
true
),
new
String
[]{
"SERIAL"
}
new
String
[]{
"SERIAL"
}
);
);
add
(
Value
.
LONG
,
Types
.
BIGINT
,
add
(
Value
.
LONG
,
Types
.
BIGINT
,
createDecimal
(
ValueLong
.
PRECISION
,
ValueLong
.
PRECISION
,
0
,
createNumeric
(
ValueLong
.
PRECISION
,
0
,
false
),
false
,
false
),
new
String
[]{
"BIGINT"
,
"INT8"
,
"LONG"
}
new
String
[]{
"BIGINT"
,
"INT8"
,
"LONG"
}
);
);
add
(
Value
.
LONG
,
Types
.
BIGINT
,
add
(
Value
.
LONG
,
Types
.
BIGINT
,
createDecimal
(
ValueLong
.
PRECISION
,
ValueLong
.
PRECISION
,
0
,
createNumeric
(
ValueLong
.
PRECISION
,
0
,
true
),
false
,
true
),
new
String
[]{
"IDENTITY"
,
"BIGSERIAL"
}
new
String
[]{
"IDENTITY"
,
"BIGSERIAL"
}
);
);
if
(
SysProperties
.
BIG_DECIMAL_IS_DECIMAL
)
{
if
(
SysProperties
.
BIG_DECIMAL_IS_DECIMAL
)
{
...
@@ -239,18 +232,15 @@ public class DataType {
...
@@ -239,18 +232,15 @@ public class DataType {
addDecimal
();
addDecimal
();
}
}
add
(
Value
.
FLOAT
,
Types
.
REAL
,
add
(
Value
.
FLOAT
,
Types
.
REAL
,
createDecimal
(
ValueFloat
.
PRECISION
,
ValueFloat
.
PRECISION
,
createNumeric
(
ValueFloat
.
PRECISION
,
0
,
false
),
0
,
false
,
false
),
new
String
[]
{
"REAL"
,
"FLOAT4"
}
new
String
[]
{
"REAL"
,
"FLOAT4"
}
);
);
add
(
Value
.
DOUBLE
,
Types
.
DOUBLE
,
add
(
Value
.
DOUBLE
,
Types
.
DOUBLE
,
createDecimal
(
ValueDouble
.
PRECISION
,
ValueDouble
.
PRECISION
,
createNumeric
(
ValueDouble
.
PRECISION
,
0
,
false
),
0
,
false
,
false
),
new
String
[]
{
"DOUBLE"
,
"DOUBLE PRECISION"
}
new
String
[]
{
"DOUBLE"
,
"DOUBLE PRECISION"
}
);
);
add
(
Value
.
DOUBLE
,
Types
.
FLOAT
,
add
(
Value
.
DOUBLE
,
Types
.
FLOAT
,
createDecimal
(
ValueDouble
.
PRECISION
,
ValueDouble
.
PRECISION
,
createNumeric
(
ValueDouble
.
PRECISION
,
0
,
false
),
0
,
false
,
false
),
new
String
[]
{
"FLOAT"
,
"FLOAT8"
}
new
String
[]
{
"FLOAT"
,
"FLOAT8"
}
);
);
add
(
Value
.
TIME
,
Types
.
TIME
,
add
(
Value
.
TIME
,
Types
.
TIME
,
...
@@ -352,20 +342,14 @@ public class DataType {
...
@@ -352,20 +342,14 @@ public class DataType {
private
static
void
addDecimal
()
{
private
static
void
addDecimal
()
{
add
(
Value
.
DECIMAL
,
Types
.
DECIMAL
,
add
(
Value
.
DECIMAL
,
Types
.
DECIMAL
,
createDecimal
(
Integer
.
MAX_VALUE
,
createNumeric
(
Integer
.
MAX_VALUE
,
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
),
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
,
true
,
false
),
new
String
[]{
"DECIMAL"
,
"DEC"
}
new
String
[]{
"DECIMAL"
,
"DEC"
}
);
);
}
}
private
static
void
addNumeric
()
{
private
static
void
addNumeric
()
{
add
(
Value
.
DECIMAL
,
Types
.
NUMERIC
,
add
(
Value
.
DECIMAL
,
Types
.
NUMERIC
,
createDecimal
(
Integer
.
MAX_VALUE
,
createNumeric
(
Integer
.
MAX_VALUE
,
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
),
ValueDecimal
.
DEFAULT_PRECISION
,
ValueDecimal
.
DEFAULT_SCALE
,
true
,
false
),
new
String
[]{
"NUMERIC"
,
"NUMBER"
}
new
String
[]{
"NUMERIC"
,
"NUMBER"
}
);
);
}
}
...
@@ -423,31 +407,41 @@ public class DataType {
...
@@ -423,31 +407,41 @@ public class DataType {
}
}
}
}
/**
* Create a width numeric data type without parameters.
*
* @param precision precision
* @param scale scale
* @param autoInc whether the data type is an auto-increment type
* @return data type
*/
public
static
DataType
createNumeric
(
int
precision
,
int
scale
,
boolean
autoInc
)
{
DataType
dataType
=
new
DataType
();
dataType
.
defaultPrecision
=
dataType
.
maxPrecision
=
precision
;
dataType
.
defaultScale
=
dataType
.
maxScale
=
dataType
.
minScale
=
scale
;
dataType
.
decimal
=
true
;
dataType
.
autoIncrement
=
autoInc
;
return
dataType
;
}
/**
/**
* Create a numeric data type.
* Create a numeric data type.
*
*
* @param maxPrecision maximum supported precision
* @param maxPrecision maximum supported precision
* @param defaultPrecision default precision
* @param defaultPrecision default precision
* @param defaultScale default scale
* @param defaultScale default scale
* @param needsPrecisionAndScale where precision and scale are supported
* @param autoInc whether the data type is an auto-increment type
* @return data type
* @return data type
*/
*/
public
static
DataType
createDecimal
(
int
maxPrecision
,
public
static
DataType
createNumeric
(
int
maxPrecision
,
int
defaultPrecision
,
int
defaultScale
)
{
int
defaultPrecision
,
int
defaultScale
,
boolean
needsPrecisionAndScale
,
boolean
autoInc
)
{
DataType
dataType
=
new
DataType
();
DataType
dataType
=
new
DataType
();
dataType
.
maxPrecision
=
maxPrecision
;
dataType
.
maxPrecision
=
maxPrecision
;
dataType
.
defaultPrecision
=
defaultPrecision
;
dataType
.
defaultPrecision
=
defaultPrecision
;
dataType
.
defaultScale
=
defaultScale
;
dataType
.
defaultScale
=
defaultScale
;
if
(
needsPrecisionAndScale
)
{
dataType
.
params
=
"PRECISION,SCALE"
;
dataType
.
params
=
"PRECISION,SCALE"
;
dataType
.
supportsPrecision
=
true
;
dataType
.
supportsPrecision
=
true
;
dataType
.
supportsScale
=
true
;
dataType
.
supportsScale
=
true
;
dataType
.
maxScale
=
maxPrecision
;
dataType
.
maxScale
=
maxPrecision
;
}
dataType
.
decimal
=
true
;
dataType
.
decimal
=
true
;
dataType
.
autoIncrement
=
autoInc
;
return
dataType
;
return
dataType
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论