Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6391467e
提交
6391467e
authored
3月 07, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
0a8384cb
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
146 行增加
和
8 行删除
+146
-8
DataPage.java
h2/src/main/org/h2/store/DataPage.java
+7
-7
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+8
-0
FileStore.java
h2/src/main/org/h2/store/FileStore.java
+33
-1
Column.java
h2/src/main/org/h2/table/Column.java
+8
-0
LinkSchema.java
h2/src/main/org/h2/table/LinkSchema.java
+13
-0
FileUtils.java
h2/src/main/org/h2/util/FileUtils.java
+11
-0
IOUtils.java
h2/src/main/org/h2/util/IOUtils.java
+9
-0
JdbcUtils.java
h2/src/main/org/h2/util/JdbcUtils.java
+9
-0
MathUtils.java
h2/src/main/org/h2/util/MathUtils.java
+10
-0
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+9
-0
DataType.java
h2/src/main/org/h2/value/DataType.java
+18
-0
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+11
-0
没有找到文件。
h2/src/main/org/h2/store/DataPage.java
浏览文件 @
6391467e
...
...
@@ -414,12 +414,12 @@ public abstract class DataPage {
}
public
Value
readValue
()
throws
SQLException
{
int
t
ype
=
data
[
pos
++];
if
(
t
ype
==
'-'
)
{
int
dataT
ype
=
data
[
pos
++];
if
(
dataT
ype
==
'-'
)
{
return
ValueNull
.
INSTANCE
;
}
type
=
(
t
ype
-
'a'
);
switch
(
t
ype
)
{
dataType
=
(
dataT
ype
-
'a'
);
switch
(
dataT
ype
)
{
case
Value
.
BOOLEAN
:
return
ValueBoolean
.
get
(
readInt
()
==
1
);
case
Value
.
BYTE
:
...
...
@@ -472,7 +472,7 @@ public abstract class DataPage {
if
(
smallLen
>=
0
)
{
byte
[]
small
=
new
byte
[
smallLen
];
read
(
small
,
0
,
smallLen
);
return
ValueLob
.
createSmallLob
(
t
ype
,
small
);
return
ValueLob
.
createSmallLob
(
dataT
ype
,
small
);
}
else
{
int
tableId
=
readInt
();
int
objectId
=
readInt
();
...
...
@@ -483,7 +483,7 @@ public abstract class DataPage {
precision
=
readLong
();
compression
=
readByte
()
==
1
;
}
ValueLob
lob
=
ValueLob
.
open
(
t
ype
,
handler
,
tableId
,
objectId
,
precision
,
compression
);
ValueLob
lob
=
ValueLob
.
open
(
dataT
ype
,
handler
,
tableId
,
objectId
,
precision
,
compression
);
if
(
smallLen
==
-
3
)
{
lob
.
setFileName
(
readString
());
}
...
...
@@ -499,7 +499,7 @@ public abstract class DataPage {
return
ValueArray
.
get
(
list
);
}
default
:
throw
Message
.
getInternalError
(
"type="
+
t
ype
);
throw
Message
.
getInternalError
(
"type="
+
dataT
ype
);
}
}
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
6391467e
...
...
@@ -938,6 +938,14 @@ public class DiskFile implements CacheWriter {
}
}
/**
* Add a redo-log entry to the redo buffer.
*
* @param storage the storage
* @param recordId the record id of the entry
* @param blockCount the number of blocks
* @param rec the record
*/
public
void
addRedoLog
(
Storage
storage
,
int
recordId
,
int
blockCount
,
DataPage
rec
)
throws
SQLException
{
synchronized
(
database
)
{
byte
[]
data
=
null
;
...
...
h2/src/main/org/h2/store/FileStore.java
浏览文件 @
6391467e
...
...
@@ -39,15 +39,47 @@ public class FileStore {
private
boolean
checkedWriting
=
true
;
private
boolean
synchronousMode
;
private
String
mode
;
/**
* Open a non encrypted file store with the given settings.
*
* @param handler the data handler
* @param name the file name
* @param mode the access mode (r, rw, rws, rwd)
* @param magic the file header magic bytes
* @return the created object
*/
public
static
FileStore
open
(
DataHandler
handler
,
String
name
,
String
mode
,
byte
[]
magic
)
throws
SQLException
{
return
open
(
handler
,
name
,
mode
,
magic
,
null
,
null
,
0
);
}
/**
* Open an encrypted file store with the given settings.
*
* @param handler the data handler
* @param name the file name
* @param mode the access mode (r, rw, rws, rwd)
* @param magic the file header magic bytes
* @param cipher the name of the cipher algorithm
* @param key the encryption key
* @return the created object
*/
public
static
FileStore
open
(
DataHandler
handler
,
String
name
,
String
mode
,
byte
[]
magic
,
String
cipher
,
byte
[]
key
)
throws
SQLException
{
return
open
(
handler
,
name
,
mode
,
magic
,
cipher
,
key
,
Constants
.
ENCRYPTION_KEY_HASH_ITERATIONS
);
}
/**
* Open an encrypted file store with the given settings.
*
* @param handler the data handler
* @param name the file name
* @param mode the access mode (r, rw, rws, rwd)
* @param magic the file header magic bytes
* @param cipher the name of the cipher algorithm
* @param key the encryption key
* @param keyIterations the number of iterations the key should be hashed
* @return the created object
*/
public
static
FileStore
open
(
DataHandler
handler
,
String
name
,
String
mode
,
byte
[]
magic
,
String
cipher
,
byte
[]
key
,
int
keyIterations
)
throws
SQLException
{
FileStore
store
;
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
6391467e
...
...
@@ -271,6 +271,14 @@ public class Column {
}
}
/**
* Convert the auto-increment flag to a sequence that is linked with this table.
*
* @param session the session
* @param schema the schema where the sequence should be generated
* @param id the object id
* @param temporary true if the sequence is temporary and does not need to be stored
*/
public
void
convertAutoIncrementToSequence
(
Session
session
,
Schema
schema
,
int
id
,
boolean
temporary
)
throws
SQLException
{
if
(!
autoIncrement
)
{
...
...
h2/src/main/org/h2/table/LinkSchema.java
浏览文件 @
6391467e
...
...
@@ -19,6 +19,19 @@ import org.h2.util.StringUtils;
* A utility class to create table links for a whole schema.
*/
public
class
LinkSchema
{
/**
* Link all tables of a schema to the database.
*
* @param conn the connection to the database where the links are to be created
* @param targetSchema the schema name where the objects should be created
* @param driver the driver class name of the linked database
* @param url the database URL of the linked database
* @param user the user name
* @param password the password
* @param sourceSchema the schema where the existing tables are
* @return a result set with the created tables
*/
public
static
ResultSet
linkSchema
(
Connection
conn
,
String
targetSchema
,
String
driver
,
String
url
,
String
user
,
String
password
,
String
sourceSchema
)
throws
SQLException
{
Connection
c2
=
null
;
...
...
h2/src/main/org/h2/util/FileUtils.java
浏览文件 @
6391467e
...
...
@@ -124,6 +124,17 @@ public class FileUtils {
return
FileSystem
.
getInstance
(
fileName
).
length
(
fileName
);
}
/**
* Create a new temporary file.
*
* @param prefix the prefix of the file name (including directory name if
* required)
* @param suffix the suffix
* @param deleteOnExit if the file should be deleted when the virtual
* machine exists
* @param inTempDir if the file should be stored in the temporary directory
* @return the name of the created file
*/
public
static
String
createTempFile
(
String
prefix
,
String
suffix
,
boolean
deleteOnExit
,
boolean
inTempDir
)
throws
IOException
,
SQLException
{
return
FileSystem
.
getInstance
(
prefix
).
createTempFile
(
prefix
,
suffix
,
deleteOnExit
,
inTempDir
);
...
...
h2/src/main/org/h2/util/IOUtils.java
浏览文件 @
6391467e
...
...
@@ -190,6 +190,15 @@ public class IOUtils {
}
}
/**
* Read the given number of bytes to the buffer.
*
* @param in the input stream
* @param buffer the output buffer
* @param off the offset in the buffer
* @param max the number of bytes to read at most
* @return the number of bytes read
*/
public
static
int
readFully
(
InputStream
in
,
byte
[]
buffer
,
int
off
,
int
max
)
throws
IOException
{
int
len
=
Math
.
min
(
max
,
buffer
.
length
);
int
result
=
0
;
...
...
h2/src/main/org/h2/util/JdbcUtils.java
浏览文件 @
6391467e
...
...
@@ -77,6 +77,15 @@ public class JdbcUtils {
}
//#endif
/**
* Create a new database connection with the given settings.
*
* @param driver the driver class name
* @param url the database URL
* @param user the user name
* @param password the password
* @return the database connection
*/
public
static
Connection
getConnection
(
String
driver
,
String
url
,
String
user
,
String
password
)
throws
SQLException
{
Properties
prop
=
new
Properties
();
prop
.
setProperty
(
"user"
,
user
);
...
...
h2/src/main/org/h2/util/MathUtils.java
浏览文件 @
6391467e
...
...
@@ -38,6 +38,16 @@ public class MathUtils {
return
(
int
)
i
;
}
/**
* Increase the value by about 50%. The method is used to increase the file size
* in larger steps.
*
* @param start the smallest possible returned value
* @param min the current value
* @param blockSize the block size
* @param maxIncrease the maximum increment
* @return the new value
*/
public
static
long
scaleUp50Percent
(
long
start
,
long
min
,
long
blockSize
,
long
maxIncrease
)
{
long
len
;
if
(
min
>
maxIncrease
*
2
)
{
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
6391467e
...
...
@@ -636,6 +636,15 @@ public class StringUtils {
return
sql
;
}
/**
* Pad a string. This method is used for the SQL function RPAD and LPAD.
*
* @param string the original string
* @param n the target length
* @param padding the padding string
* @param right true if the padding should be appended at the end
* @return the padded string
*/
public
static
String
pad
(
String
string
,
int
n
,
String
padding
,
boolean
right
)
{
if
(
n
<
0
)
{
n
=
0
;
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
6391467e
...
...
@@ -326,6 +326,15 @@ public class DataType {
return
types
;
}
/**
* Read a value from the given result set.
*
* @param session the session
* @param rs the result set
* @param columnIndex the column index (1 based)
* @param type the data type
* @return the value
*/
public
static
Value
readValue
(
SessionInterface
session
,
ResultSet
rs
,
int
columnIndex
,
int
type
)
throws
SQLException
{
Value
v
;
switch
(
type
)
{
...
...
@@ -746,6 +755,15 @@ public class DataType {
}
}
/**
* Convert a value to the specified class.
*
* @param session the session
* @param conn the database connection
* @param v the value
* @param paramClass the target class
* @return the converted object
*/
public
static
Object
convertTo
(
SessionInterface
session
,
JdbcConnection
conn
,
Value
v
,
Class
paramClass
)
throws
SQLException
{
if
(
paramClass
==
java
.
sql
.
Blob
.
class
)
{
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
6391467e
...
...
@@ -104,6 +104,17 @@ public class ValueLob extends Value {
}
}
/**
* Create a LOB value with the given parameters.
*
* @param type the data type
* @param handler the file handler
* @param tableId the table object id
* @param objectId the object id
* @param precision the precision (length in elements)
* @param compression if compression is used
* @return the value object
*/
public
static
ValueLob
open
(
int
type
,
DataHandler
handler
,
int
tableId
,
int
objectId
,
long
precision
,
boolean
compression
)
{
String
fileName
=
getFileName
(
handler
,
tableId
,
objectId
);
return
new
ValueLob
(
type
,
handler
,
fileName
,
tableId
,
objectId
,
true
,
precision
,
compression
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论