Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d0ecd064
提交
d0ecd064
authored
11月 06, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Value.getSQL(StringBuilder)
上级
07154efb
隐藏空白字符变更
内嵌
并排
正在显示
37 个修改的文件
包含
212 行增加
和
82 行删除
+212
-82
Interval.java
h2/src/main/org/h2/api/Interval.java
+2
-1
TimestampWithTimeZone.java
h2/src/main/org/h2/api/TimestampWithTimeZone.java
+4
-1
Prepared.java
h2/src/main/org/h2/command/Prepared.java
+1
-1
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+2
-2
Expression.java
h2/src/main/org/h2/expression/Expression.java
+1
-3
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+1
-1
Constant.java
h2/src/main/org/h2/schema/Constant.java
+2
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+3
-2
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+2
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-1
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+3
-4
IntervalUtils.java
h2/src/main/org/h2/util/IntervalUtils.java
+9
-8
Value.java
h2/src/main/org/h2/value/Value.java
+12
-1
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+11
-8
ValueBoolean.java
h2/src/main/org/h2/value/ValueBoolean.java
+5
-0
ValueByte.java
h2/src/main/org/h2/value/ValueByte.java
+6
-1
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+2
-2
ValueDate.java
h2/src/main/org/h2/value/ValueDate.java
+4
-2
ValueDecimal.java
h2/src/main/org/h2/value/ValueDecimal.java
+5
-0
ValueDouble.java
h2/src/main/org/h2/value/ValueDouble.java
+14
-0
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+5
-0
ValueFloat.java
h2/src/main/org/h2/value/ValueFloat.java
+15
-2
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+2
-2
ValueInt.java
h2/src/main/org/h2/value/ValueInt.java
+6
-1
ValueInterval.java
h2/src/main/org/h2/value/ValueInterval.java
+4
-3
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+12
-6
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+12
-6
ValueLong.java
h2/src/main/org/h2/value/ValueLong.java
+6
-1
ValueNull.java
h2/src/main/org/h2/value/ValueNull.java
+5
-0
ValueResultSet.java
h2/src/main/org/h2/value/ValueResultSet.java
+5
-0
ValueShort.java
h2/src/main/org/h2/value/ValueShort.java
+6
-1
ValueString.java
h2/src/main/org/h2/value/ValueString.java
+5
-0
ValueTime.java
h2/src/main/org/h2/value/ValueTime.java
+4
-2
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+6
-2
ValueTimestampTimeZone.java
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
+7
-3
ValueUuid.java
h2/src/main/org/h2/value/ValueUuid.java
+17
-13
TestCustomDataTypesHandler.java
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
+5
-0
没有找到文件。
h2/src/main/org/h2/api/Interval.java
浏览文件 @
d0ecd064
...
@@ -628,7 +628,8 @@ public final class Interval {
...
@@ -628,7 +628,8 @@ public final class Interval {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
IntervalUtils
.
intervalToString
(
qualifier
,
negative
,
leading
,
remaining
);
return
IntervalUtils
.
appendInterval
(
new
StringBuilder
(),
getQualifier
(),
negative
,
leading
,
remaining
)
.
toString
();
}
}
}
}
h2/src/main/org/h2/api/TimestampWithTimeZone.java
浏览文件 @
d0ecd064
...
@@ -7,6 +7,7 @@ package org.h2.api;
...
@@ -7,6 +7,7 @@ package org.h2.api;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.value.ValueTimestampTimeZone
;
/**
/**
* How we expose "TIMESTAMP WITH TIME ZONE" in our ResultSets.
* How we expose "TIMESTAMP WITH TIME ZONE" in our ResultSets.
...
@@ -109,7 +110,9 @@ public class TimestampWithTimeZone implements Serializable, Cloneable {
...
@@ -109,7 +110,9 @@ public class TimestampWithTimeZone implements Serializable, Cloneable {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
DateTimeUtils
.
timestampTimeZoneToString
(
dateValue
,
timeNanos
,
timeZoneOffsetMins
);
StringBuilder
builder
=
new
StringBuilder
(
ValueTimestampTimeZone
.
MAXIMUM_PRECISION
);
DateTimeUtils
.
appendTimestampTimeZone
(
builder
,
dateValue
,
timeNanos
,
timeZoneOffsetMins
);
return
builder
.
toString
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/command/Prepared.java
浏览文件 @
d0ecd064
...
@@ -405,7 +405,7 @@ public abstract class Prepared {
...
@@ -405,7 +405,7 @@ public abstract class Prepared {
for
(
Value
v
:
values
)
{
for
(
Value
v
:
values
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
if
(
v
!=
null
)
{
if
(
v
!=
null
)
{
buff
.
append
(
v
.
getSQL
());
v
.
getSQL
(
buff
.
builder
());
}
}
}
}
return
buff
.
toString
();
return
buff
.
toString
();
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
d0ecd064
...
@@ -422,10 +422,10 @@ public class ScriptCommand extends ScriptBase {
...
@@ -422,10 +422,10 @@ public class ScriptCommand extends ScriptBase {
id
=
writeLobStream
(
v
);
id
=
writeLobStream
(
v
);
buff
.
append
(
"SYSTEM_COMBINE_BLOB("
).
append
(
id
).
append
(
')'
);
buff
.
append
(
"SYSTEM_COMBINE_BLOB("
).
append
(
id
).
append
(
')'
);
}
else
{
}
else
{
buff
.
append
(
v
.
getSQL
());
v
.
getSQL
(
buff
.
builder
());
}
}
}
else
{
}
else
{
buff
.
append
(
v
.
getSQL
());
v
.
getSQL
(
buff
.
builder
());
}
}
}
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
d0ecd064
...
@@ -111,9 +111,7 @@ public abstract class Expression {
...
@@ -111,9 +111,7 @@ public abstract class Expression {
* @return the SQL statement
* @return the SQL statement
*/
*/
public
String
getSQL
()
{
public
String
getSQL
()
{
StringBuilder
builder
=
new
StringBuilder
();
return
getSQL
(
new
StringBuilder
()).
toString
();
getSQL
(
builder
);
return
builder
.
toString
();
}
}
/**
/**
...
...
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
d0ecd064
...
@@ -147,7 +147,7 @@ public class ValueExpression extends Expression {
...
@@ -147,7 +147,7 @@ public class ValueExpression extends Expression {
if
(
this
==
DEFAULT
)
{
if
(
this
==
DEFAULT
)
{
builder
.
append
(
"DEFAULT"
);
builder
.
append
(
"DEFAULT"
);
}
else
{
}
else
{
builder
.
append
(
value
.
getSQL
()
);
value
.
getSQL
(
builder
);
}
}
return
builder
;
return
builder
;
}
}
...
...
h2/src/main/org/h2/schema/Constant.java
浏览文件 @
d0ecd064
...
@@ -38,7 +38,8 @@ public class Constant extends SchemaObjectBase {
...
@@ -38,7 +38,8 @@ public class Constant extends SchemaObjectBase {
@Override
@Override
public
String
getCreateSQL
()
{
public
String
getCreateSQL
()
{
return
"CREATE CONSTANT "
+
getSQL
()
+
" VALUE "
+
value
.
getSQL
();
StringBuilder
builder
=
new
StringBuilder
().
append
(
"CREATE CONSTANT "
).
append
(
getSQL
()).
append
(
" VALUE "
);
return
value
.
getSQL
(
builder
).
toString
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
d0ecd064
...
@@ -1896,11 +1896,12 @@ public class MetaTable extends Table {
...
@@ -1896,11 +1896,12 @@ public class MetaTable extends Table {
case
SESSION_STATE:
{
case
SESSION_STATE:
{
for
(
String
name
:
session
.
getVariableNames
())
{
for
(
String
name
:
session
.
getVariableNames
())
{
Value
v
=
session
.
getVariable
(
name
);
Value
v
=
session
.
getVariable
(
name
);
StringBuilder
builder
=
new
StringBuilder
().
append
(
"SET @"
).
append
(
name
).
append
(
' '
);
v
.
getSQL
(
builder
);
add
(
rows
,
add
(
rows
,
// KEY
// KEY
"@"
+
name
,
"@"
+
name
,
// SQL
builder
.
toString
()
"SET @"
+
name
+
" "
+
v
.
getSQL
()
);
);
}
}
for
(
Table
table
:
session
.
getLocalTempTables
())
{
for
(
Table
table
:
session
.
getLocalTempTables
())
{
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
d0ecd064
...
@@ -510,7 +510,8 @@ public class TableLink extends Table {
...
@@ -510,7 +510,8 @@ public class TableLink extends Table {
int
i
=
1
;
int
i
=
1
;
for
(
Value
v
:
params
)
{
for
(
Value
v
:
params
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
i
++).
append
(
": "
).
append
(
v
.
getSQL
());
buff
.
append
(
i
++).
append
(
": "
);
v
.
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
'}'
);
buff
.
append
(
'}'
);
}
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
d0ecd064
...
@@ -991,7 +991,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -991,7 +991,7 @@ public class Recover extends Tool implements DataHandler {
append
(
" VALUES("
);
append
(
" VALUES("
);
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
row
.
getValue
(
i
).
getSQL
());
row
.
getValue
(
i
).
getSQL
(
buff
.
builder
());
}
}
buff
.
append
(
");"
);
buff
.
append
(
");"
);
writer
.
println
(
buff
.
toString
());
writer
.
println
(
buff
.
toString
());
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
d0ecd064
...
@@ -1511,18 +1511,17 @@ public class DateTimeUtils {
...
@@ -1511,18 +1511,17 @@ public class DateTimeUtils {
/**
/**
* Formats timestamp with time zone as string.
* Formats timestamp with time zone as string.
*
*
* @param buff the target string builder
* @param dateValue the year-month-day bit field
* @param dateValue the year-month-day bit field
* @param timeNanos nanoseconds since midnight
* @param timeNanos nanoseconds since midnight
* @param timeZoneOffsetMins the time zone offset in minutes
* @param timeZoneOffsetMins the time zone offset in minutes
* @return formatted string
*/
*/
public
static
String
timestampTimeZoneToString
(
long
dateValue
,
long
timeNanos
,
short
timeZoneOffsetMins
)
{
public
static
void
appendTimestampTimeZone
(
StringBuilder
buff
,
long
dateValue
,
long
timeNanos
,
StringBuilder
buff
=
new
StringBuilder
(
ValueTimestampTimeZone
.
MAXIMUM_PRECISION
);
short
timeZoneOffsetMins
)
{
appendDate
(
buff
,
dateValue
);
appendDate
(
buff
,
dateValue
);
buff
.
append
(
' '
);
buff
.
append
(
' '
);
appendTime
(
buff
,
timeNanos
);
appendTime
(
buff
,
timeNanos
);
appendTimeZone
(
buff
,
timeZoneOffsetMins
);
appendTimeZone
(
buff
,
timeZoneOffsetMins
);
return
buff
.
toString
();
}
}
/**
/**
...
...
h2/src/main/org/h2/util/IntervalUtils.java
浏览文件 @
d0ecd064
...
@@ -383,8 +383,11 @@ public class IntervalUtils {
...
@@ -383,8 +383,11 @@ public class IntervalUtils {
}
}
/**
/**
* Formats interval as a string.
* Formats interval as a string and appends it to a specified string
* builder.
*
*
* @param buff
* string builder to append to
* @param qualifier
* @param qualifier
* qualifier of the interval
* qualifier of the interval
* @param negative
* @param negative
...
@@ -393,12 +396,11 @@ public class IntervalUtils {
...
@@ -393,12 +396,11 @@ public class IntervalUtils {
* the value of leading field
* the value of leading field
* @param remaining
* @param remaining
* the value of all remaining fields
* the value of all remaining fields
* @return
string representation of the specified interval
* @return
the specified string builder
*/
*/
public
static
String
intervalToString
(
IntervalQualifier
qualifier
,
boolean
negative
,
long
leading
,
long
remaining
)
public
static
StringBuilder
appendInterval
(
StringBuilder
buff
,
IntervalQualifier
qualifier
,
boolean
negative
,
{
long
leading
,
long
remaining
)
{
StringBuilder
buff
=
new
StringBuilder
().
append
(
"INTERVAL "
);
buff
.
append
(
"INTERVAL '"
);
buff
.
append
(
'\''
);
if
(
negative
)
{
if
(
negative
)
{
buff
.
append
(
'-'
);
buff
.
append
(
'-'
);
}
}
...
@@ -453,8 +455,7 @@ public class IntervalUtils {
...
@@ -453,8 +455,7 @@ public class IntervalUtils {
appendSecondsWithNanos
(
buff
,
remaining
);
appendSecondsWithNanos
(
buff
,
remaining
);
break
;
break
;
}
}
buff
.
append
(
"' "
).
append
(
qualifier
);
return
buff
.
append
(
"' "
).
append
(
qualifier
);
return
buff
.
toString
();
}
}
private
static
void
appendSecondsWithNanos
(
StringBuilder
buff
,
long
nanos
)
{
private
static
void
appendSecondsWithNanos
(
StringBuilder
buff
,
long
nanos
)
{
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
d0ecd064
...
@@ -275,7 +275,18 @@ public abstract class Value {
...
@@ -275,7 +275,18 @@ public abstract class Value {
*
*
* @return the SQL expression
* @return the SQL expression
*/
*/
public
abstract
String
getSQL
();
public
String
getSQL
()
{
return
getSQL
(
new
StringBuilder
()).
toString
();
}
/**
* Appends the SQL expression for this value to the specified builder.
*
* @param builder
* string builder
* @return the specified string builder
*/
public
abstract
StringBuilder
getSQL
(
StringBuilder
builder
);
/**
/**
* Get the value type.
* Get the value type.
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
d0ecd064
...
@@ -155,16 +155,19 @@ public class ValueArray extends Value {
...
@@ -155,16 +155,19 @@ public class ValueArray extends Value {
}
}
@Override
@Override
public
String
getSQL
()
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
"("
);
builder
.
append
(
'('
);
for
(
Value
v
:
values
)
{
int
length
=
values
.
length
;
buff
.
appendExceptFirst
(
", "
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
buff
.
append
(
v
.
getSQL
());
if
(
i
>
0
)
{
builder
.
append
(
", "
);
}
values
[
i
].
getSQL
(
builder
);
}
}
if
(
values
.
length
==
1
)
{
if
(
length
==
1
)
{
bu
ff
.
append
(
','
);
bu
ilder
.
append
(
','
);
}
}
return
bu
ff
.
append
(
')'
).
toString
(
);
return
bu
ilder
.
append
(
')'
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueBoolean.java
浏览文件 @
d0ecd064
...
@@ -50,6 +50,11 @@ public class ValueBoolean extends Value {
...
@@ -50,6 +50,11 @@ public class ValueBoolean extends Value {
return
getString
();
return
getString
();
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
getString
());
}
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
return
value
?
"TRUE"
:
"FALSE"
;
return
value
?
"TRUE"
:
"FALSE"
;
...
...
h2/src/main/org/h2/value/ValueByte.java
浏览文件 @
d0ecd064
...
@@ -89,7 +89,12 @@ public class ValueByte extends Value {
...
@@ -89,7 +89,12 @@ public class ValueByte extends Value {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
return
getString
();
return
Integer
.
toString
(
value
);
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
value
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
d0ecd064
...
@@ -79,8 +79,8 @@ public class ValueBytes extends Value {
...
@@ -79,8 +79,8 @@ public class ValueBytes extends Value {
}
}
@Override
@Override
public
String
getSQL
(
)
{
public
String
Builder
getSQL
(
StringBuilder
builder
)
{
return
"X'"
+
StringUtils
.
convertBytesToHex
(
getBytesNoCopy
())
+
"'"
;
return
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytesNoCopy
())).
append
(
'\''
)
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueDate.java
浏览文件 @
d0ecd064
...
@@ -98,8 +98,10 @@ public class ValueDate extends Value {
...
@@ -98,8 +98,10 @@ public class ValueDate extends Value {
}
}
@Override
@Override
public
String
getSQL
()
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
"DATE '"
+
getString
()
+
"'"
;
builder
.
append
(
"DATE '"
);
DateTimeUtils
.
appendDate
(
builder
,
dateValue
);
return
builder
.
append
(
'\''
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueDecimal.java
浏览文件 @
d0ecd064
...
@@ -121,6 +121,11 @@ public class ValueDecimal extends Value {
...
@@ -121,6 +121,11 @@ public class ValueDecimal extends Value {
return
getString
();
return
getString
();
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
getString
());
}
@Override
@Override
public
int
getType
()
{
public
int
getType
()
{
return
Value
.
DECIMAL
;
return
Value
.
DECIMAL
;
...
...
h2/src/main/org/h2/value/ValueDouble.java
浏览文件 @
d0ecd064
...
@@ -103,6 +103,20 @@ public class ValueDouble extends Value {
...
@@ -103,6 +103,20 @@ public class ValueDouble extends Value {
return
getString
();
return
getString
();
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
value
==
Double
.
POSITIVE_INFINITY
)
{
builder
.
append
(
"POWER(0, -1)"
);
}
else
if
(
value
==
Double
.
NEGATIVE_INFINITY
)
{
builder
.
append
(
"(-POWER(0, -1))"
);
}
else
if
(
Double
.
isNaN
(
value
))
{
builder
.
append
(
"SQRT(-1)"
);
}
else
{
builder
.
append
(
value
);
}
return
builder
;
}
@Override
@Override
public
int
getType
()
{
public
int
getType
()
{
return
Value
.
DOUBLE
;
return
Value
.
DOUBLE
;
...
...
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
d0ecd064
...
@@ -98,6 +98,11 @@ public class ValueEnumBase extends Value {
...
@@ -98,6 +98,11 @@ public class ValueEnumBase extends Value {
return
StringUtils
.
quoteStringSQL
(
label
);
return
StringUtils
.
quoteStringSQL
(
label
);
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
StringUtils
.
quoteStringSQL
(
label
));
}
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
return
label
;
return
label
;
...
...
h2/src/main/org/h2/value/ValueFloat.java
浏览文件 @
d0ecd064
...
@@ -98,10 +98,23 @@ public class ValueFloat extends Value {
...
@@ -98,10 +98,23 @@ public class ValueFloat extends Value {
}
else
if
(
value
==
Float
.
NEGATIVE_INFINITY
)
{
}
else
if
(
value
==
Float
.
NEGATIVE_INFINITY
)
{
return
"(-POWER(0, -1))"
;
return
"(-POWER(0, -1))"
;
}
else
if
(
Float
.
isNaN
(
value
))
{
}
else
if
(
Float
.
isNaN
(
value
))
{
// NaN
return
"SQRT(-1)"
;
return
"SQRT(-1)"
;
}
}
return
getString
();
return
Float
.
toString
(
value
);
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
value
==
Float
.
POSITIVE_INFINITY
)
{
builder
.
append
(
"POWER(0, -1)"
);
}
else
if
(
value
==
Float
.
NEGATIVE_INFINITY
)
{
builder
.
append
(
"(-POWER(0, -1))"
);
}
else
if
(
Float
.
isNaN
(
value
))
{
builder
.
append
(
"SQRT(-1)"
);
}
else
{
builder
.
append
(
value
);
}
return
builder
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
d0ecd064
...
@@ -268,9 +268,9 @@ public class ValueGeometry extends Value {
...
@@ -268,9 +268,9 @@ public class ValueGeometry extends Value {
}
}
@Override
@Override
public
String
getSQL
(
)
{
public
String
Builder
getSQL
(
StringBuilder
builder
)
{
// Using bytes is faster than converting to EWKT.
// Using bytes is faster than converting to EWKT.
return
"X'"
+
StringUtils
.
convertBytesToHex
(
getBytesNoCopy
())
+
"'::Geometry"
;
return
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytesNoCopy
())).
append
(
"'::Geometry"
)
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueInt.java
浏览文件 @
d0ecd064
...
@@ -122,7 +122,12 @@ public class ValueInt extends Value {
...
@@ -122,7 +122,12 @@ public class ValueInt extends Value {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
return
getString
();
return
Integer
.
toString
(
value
);
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
value
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueInterval.java
浏览文件 @
d0ecd064
...
@@ -138,8 +138,8 @@ public class ValueInterval extends Value {
...
@@ -138,8 +138,8 @@ public class ValueInterval extends Value {
}
}
@Override
@Override
public
String
getSQL
(
)
{
public
String
Builder
getSQL
(
StringBuilder
builder
)
{
return
getString
(
);
return
IntervalUtils
.
appendInterval
(
builder
,
getQualifier
(),
negative
,
leading
,
remaining
);
}
}
@Override
@Override
...
@@ -211,7 +211,8 @@ public class ValueInterval extends Value {
...
@@ -211,7 +211,8 @@ public class ValueInterval extends Value {
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
return
IntervalUtils
.
intervalToString
(
getQualifier
(),
negative
,
leading
,
remaining
);
return
IntervalUtils
.
appendInterval
(
new
StringBuilder
(),
getQualifier
(),
negative
,
leading
,
remaining
)
.
toString
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
d0ecd064
...
@@ -571,14 +571,20 @@ public class ValueLob extends Value {
...
@@ -571,14 +571,20 @@ public class ValueLob extends Value {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
String
s
;
if
(
valueType
==
Value
.
CLOB
)
{
if
(
valueType
==
Value
.
CLOB
)
{
s
=
getString
();
return
StringUtils
.
quoteStringSQL
(
getString
());
return
StringUtils
.
quoteStringSQL
(
s
);
}
}
byte
[]
buff
=
getBytes
();
return
"X'"
+
StringUtils
.
convertBytesToHex
(
getBytes
())
+
'\''
;
s
=
StringUtils
.
convertBytesToHex
(
buff
);
}
return
"X'"
+
s
+
"'"
;
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
valueType
==
Value
.
CLOB
)
{
builder
.
append
(
StringUtils
.
quoteStringSQL
(
getString
()));
}
else
{
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytes
())).
append
(
'\''
);
}
return
builder
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
d0ecd064
...
@@ -462,14 +462,20 @@ public class ValueLobDb extends Value {
...
@@ -462,14 +462,20 @@ public class ValueLobDb extends Value {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
String
s
;
if
(
valueType
==
Value
.
CLOB
)
{
if
(
valueType
==
Value
.
CLOB
)
{
s
=
getString
();
return
StringUtils
.
quoteStringSQL
(
getString
());
return
StringUtils
.
quoteStringSQL
(
s
);
}
}
byte
[]
buff
=
getBytes
();
return
"X'"
+
StringUtils
.
convertBytesToHex
(
getBytes
())
+
'\''
;
s
=
StringUtils
.
convertBytesToHex
(
buff
);
}
return
"X'"
+
s
+
"'"
;
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
valueType
==
Value
.
CLOB
)
{
builder
.
append
(
StringUtils
.
quoteStringSQL
(
getString
()));
}
else
{
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytes
())).
append
(
'\''
);
}
return
builder
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueLong.java
浏览文件 @
d0ecd064
...
@@ -147,7 +147,12 @@ public class ValueLong extends Value {
...
@@ -147,7 +147,12 @@ public class ValueLong extends Value {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
return
getString
();
return
Long
.
toString
(
value
);
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
value
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueNull.java
浏览文件 @
d0ecd064
...
@@ -53,6 +53,11 @@ public class ValueNull extends Value {
...
@@ -53,6 +53,11 @@ public class ValueNull extends Value {
return
"NULL"
;
return
"NULL"
;
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
"NULL"
);
}
@Override
@Override
public
int
getType
()
{
public
int
getType
()
{
return
Value
.
NULL
;
return
Value
.
NULL
;
...
...
h2/src/main/org/h2/value/ValueResultSet.java
浏览文件 @
d0ecd064
...
@@ -170,6 +170,11 @@ public class ValueResultSet extends Value {
...
@@ -170,6 +170,11 @@ public class ValueResultSet extends Value {
return
""
;
return
""
;
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
;
}
@Override
@Override
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
if
(!
force
)
{
if
(!
force
)
{
...
...
h2/src/main/org/h2/value/ValueShort.java
浏览文件 @
d0ecd064
...
@@ -89,7 +89,12 @@ public class ValueShort extends Value {
...
@@ -89,7 +89,12 @@ public class ValueShort extends Value {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
return
getString
();
return
Integer
.
toString
(
value
);
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
value
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueString.java
浏览文件 @
d0ecd064
...
@@ -38,6 +38,11 @@ public class ValueString extends Value {
...
@@ -38,6 +38,11 @@ public class ValueString extends Value {
return
StringUtils
.
quoteStringSQL
(
value
);
return
StringUtils
.
quoteStringSQL
(
value
);
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
StringUtils
.
quoteStringSQL
(
value
));
}
@Override
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
return
other
instanceof
ValueString
return
other
instanceof
ValueString
...
...
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
d0ecd064
...
@@ -138,8 +138,10 @@ public class ValueTime extends Value {
...
@@ -138,8 +138,10 @@ public class ValueTime extends Value {
}
}
@Override
@Override
public
String
getSQL
()
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
"TIME '"
+
getString
()
+
"'"
;
builder
.
append
(
"TIME '"
);
DateTimeUtils
.
appendTime
(
builder
,
nanos
);
return
builder
.
append
(
'\''
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
d0ecd064
...
@@ -188,8 +188,12 @@ public class ValueTimestamp extends Value {
...
@@ -188,8 +188,12 @@ public class ValueTimestamp extends Value {
}
}
@Override
@Override
public
String
getSQL
()
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
"TIMESTAMP '"
+
getString
()
+
"'"
;
builder
.
append
(
"TIMESTAMP '"
);
DateTimeUtils
.
appendDate
(
builder
,
dateValue
);
builder
.
append
(
' '
);
DateTimeUtils
.
appendTime
(
builder
,
timeNanos
);
return
builder
.
append
(
'\''
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
浏览文件 @
d0ecd064
...
@@ -175,12 +175,16 @@ public class ValueTimestampTimeZone extends Value {
...
@@ -175,12 +175,16 @@ public class ValueTimestampTimeZone extends Value {
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
return
DateTimeUtils
.
timestampTimeZoneToString
(
dateValue
,
timeNanos
,
timeZoneOffsetMins
);
StringBuilder
builder
=
new
StringBuilder
(
ValueTimestampTimeZone
.
MAXIMUM_PRECISION
);
DateTimeUtils
.
appendTimestampTimeZone
(
builder
,
dateValue
,
timeNanos
,
timeZoneOffsetMins
);
return
builder
.
toString
();
}
}
@Override
@Override
public
String
getSQL
()
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
"TIMESTAMP WITH TIME ZONE '"
+
getString
()
+
"'"
;
builder
.
append
(
"TIMESTAMP WITH TIME ZONE '"
);
DateTimeUtils
.
appendTimestampTimeZone
(
builder
,
dateValue
,
timeNanos
,
timeZoneOffsetMins
);
return
builder
.
append
(
'\''
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
d0ecd064
...
@@ -126,8 +126,9 @@ public class ValueUuid extends Value {
...
@@ -126,8 +126,9 @@ public class ValueUuid extends Value {
}
}
@Override
@Override
public
String
getSQL
()
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
StringUtils
.
quoteStringSQL
(
getString
());
builder
.
append
(
'\''
);
return
addString
(
builder
).
append
(
'\''
);
}
}
@Override
@Override
...
@@ -149,17 +150,20 @@ public class ValueUuid extends Value {
...
@@ -149,17 +150,20 @@ public class ValueUuid extends Value {
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
StringBuilder
buff
=
new
StringBuilder
(
36
);
return
addString
(
new
StringBuilder
(
36
)).
toString
();
appendHex
(
buff
,
high
>>
32
,
4
);
}
buff
.
append
(
'-'
);
appendHex
(
buff
,
high
>>
16
,
2
);
private
StringBuilder
addString
(
StringBuilder
builder
)
{
buff
.
append
(
'-'
);
appendHex
(
builder
,
high
>>
32
,
4
);
appendHex
(
buff
,
high
,
2
);
builder
.
append
(
'-'
);
buff
.
append
(
'-'
);
appendHex
(
builder
,
high
>>
16
,
2
);
appendHex
(
buff
,
low
>>
48
,
2
);
builder
.
append
(
'-'
);
buff
.
append
(
'-'
);
appendHex
(
builder
,
high
,
2
);
appendHex
(
buff
,
low
,
6
);
builder
.
append
(
'-'
);
return
buff
.
toString
();
appendHex
(
builder
,
low
>>
48
,
2
);
builder
.
append
(
'-'
);
appendHex
(
builder
,
low
,
6
);
return
builder
;
}
}
@Override
@Override
...
...
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
d0ecd064
...
@@ -341,6 +341,11 @@ public class TestCustomDataTypesHandler extends TestDb {
...
@@ -341,6 +341,11 @@ public class TestCustomDataTypesHandler extends TestDb {
return
val
.
toString
();
return
val
.
toString
();
}
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
val
.
toString
());
}
@Override
@Override
public
int
getType
()
{
public
int
getType
()
{
return
TestOnlyCustomDataTypesHandler
.
COMPLEX_DATA_TYPE_ID
;
return
TestOnlyCustomDataTypesHandler
.
COMPLEX_DATA_TYPE_ID
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论