Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c9818113
提交
c9818113
authored
6月 20, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 472: PgServer does not work with any recent Postgres JDBC driver, patch from Andrew Franklin
上级
53d6f1f9
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
58 行增加
和
21 行删除
+58
-21
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
PgServer.java
h2/src/main/org/h2/server/pg/PgServer.java
+8
-0
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+27
-13
pg_catalog.sql
h2/src/main/org/h2/server/pg/pg_catalog.sql
+22
-8
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
c9818113
...
...
@@ -40,6 +40,7 @@ Change Log
</li><li>
Issue 471: CREATE VIEW does not check user rights, patch from Andrew Franklin
</li><li>
Issue 477: PgServer binary transmission of query params is unimplemented, patch from Andrew Franklin
</li><li>
Issue 479: Support for SUBSTRING without a FROM condition, patch from Andrew Franklin
</li><li>
Issue 472: PgServer does not work with any recent Postgres JDBC driver, patch from Andrew Franklin
</li></ul>
<h2>
Version 1.3.172 (2013-05-25)
</h2>
...
...
h2/src/main/org/h2/server/pg/PgServer.java
浏览文件 @
c9818113
...
...
@@ -456,6 +456,14 @@ public class PgServer implements Service {
return
1
;
}
/**
* A fake wrapper around pg_get_expr(expr_text, relation_oid), in PG it decompiles the "internal form of an
* expression, assuming that any Vars in it refer to the relation indicated by the second parameter".
*/
public
static
String
getPgExpr
(
String
exprText
,
int
relationOid
)
{
return
null
;
}
/**
* Convert the SQL type to a PostgreSQL type
*
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
c9818113
...
...
@@ -25,6 +25,7 @@ import java.sql.ResultSet;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Types
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Properties
;
...
...
@@ -341,8 +342,7 @@ public class PgServerThread implements Runnable {
if
(
result
)
{
try
{
ResultSet
rs
=
prep
.
getResultSet
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
sendRowDescription
(
meta
);
// the meta-data is sent in the prior 'Describe'
while
(
rs
.
next
())
{
sendDataRow
(
rs
);
}
...
...
@@ -483,13 +483,21 @@ public class PgServerThread implements Runnable {
private
void
writeDataColumn
(
ResultSet
rs
,
int
column
,
int
pgType
)
throws
Exception
{
if
(
formatAsText
(
pgType
))
{
String
s
=
rs
.
getString
(
column
);
if
(
s
==
null
)
{
writeInt
(-
1
);
}
else
{
byte
[]
data
=
s
.
getBytes
(
getEncoding
());
writeInt
(
data
.
length
);
write
(
data
);
// plain text
switch
(
pgType
)
{
case
PgServer
.
PG_TYPE_BOOL
:
writeInt
(
1
);
dataOut
.
writeByte
(
rs
.
getBoolean
(
column
)
?
't'
:
'f'
);
break
;
default
:
String
s
=
rs
.
getString
(
column
);
if
(
s
==
null
)
{
writeInt
(-
1
);
}
else
{
byte
[]
data
=
s
.
getBytes
(
getEncoding
());
writeInt
(
data
.
length
);
write
(
data
);
}
}
}
else
{
// binary
...
...
@@ -540,7 +548,9 @@ public class PgServerThread implements Runnable {
boolean
text
=
(
i
>=
formatCodes
.
length
)
||
(
formatCodes
[
i
]
==
0
);
int
col
=
i
+
1
;
int
paramLen
=
readInt
();
if
(
text
)
{
if
(
paramLen
==-
1
)
{
prep
.
setNull
(
i
,
Types
.
NULL
);
}
else
if
(
text
)
{
// plain text
byte
[]
data
=
DataUtils
.
newBytes
(
paramLen
);
readFully
(
data
);
...
...
@@ -661,7 +671,7 @@ public class PgServerThread implements Runnable {
String
name
=
meta
.
getColumnName
(
i
+
1
);
names
[
i
]
=
name
;
int
type
=
meta
.
getColumnType
(
i
+
1
);
t
ype
=
PgServer
.
convertType
(
type
);
int
pgT
ype
=
PgServer
.
convertType
(
type
);
// the ODBC client needs the column pg_catalog.pg_index
// to be of type 'int2vector'
// if (name.equalsIgnoreCase("indkey") &&
...
...
@@ -669,8 +679,10 @@ public class PgServerThread implements Runnable {
// type = PgServer.PG_TYPE_INT2VECTOR;
// }
precision
[
i
]
=
meta
.
getColumnDisplaySize
(
i
+
1
);
server
.
checkType
(
type
);
types
[
i
]
=
type
;
if
(
type
!=
Types
.
NULL
)
{
server
.
checkType
(
pgType
);
}
types
[
i
]
=
pgType
;
}
startMessage
(
'T'
);
writeShort
(
columns
);
...
...
@@ -705,6 +717,8 @@ public class PgServerThread implements Runnable {
private
static
int
getTypeSize
(
int
pgType
,
int
precision
)
{
switch
(
pgType
)
{
case
PgServer
.
PG_TYPE_BOOL
:
return
1
;
case
PgServer
.
PG_TYPE_VARCHAR
:
return
Math
.
max
(
255
,
precision
+
10
);
default
:
...
...
h2/src/main/org/h2/server/pg/pg_catalog.sql
浏览文件 @
c9818113
...
...
@@ -42,7 +42,9 @@ create table pg_catalog.pg_type(
typlen
int
,
typtype
varchar
,
typbasetype
int
,
typtypmod
int
);
typtypmod
int
,
typnotnull
boolean
);
grant
select
on
pg_catalog
.
pg_type
to
public
;
insert
into
pg_catalog
.
pg_type
...
...
@@ -53,7 +55,8 @@ select
-
1
typlen
,
'c'
typtype
,
0
typbasetype
,
-
1
typtypmod
-
1
typtypmod
,
false
typnotnull
from
information_schema
.
type_info
where
pos
=
0
and
pg_convertType
(
data_type
)
<>
705
;
-- not unknown
...
...
@@ -65,7 +68,8 @@ merge into pg_catalog.pg_type values(
-
1
,
'c'
,
0
,
-
1
-
1
,
false
);
merge
into
pg_catalog
.
pg_type
values
(
0
,
...
...
@@ -74,7 +78,8 @@ merge into pg_catalog.pg_type values(
-
1
,
'c'
,
0
,
-
1
-
1
,
false
);
merge
into
pg_catalog
.
pg_type
values
(
22
,
...
...
@@ -83,7 +88,8 @@ merge into pg_catalog.pg_type values(
-
1
,
'c'
,
0
,
-
1
-
1
,
false
);
create
view
pg_catalog
.
pg_class
-- (oid, relname, relnamespace, relkind, relam, reltuples, relpages, relhasrules, relhasoids)
...
...
@@ -140,7 +146,8 @@ select
id
oid
,
0
adsrc
,
0
adrelid
,
0
adnum
0
adnum
,
null
adbin
from
information_schema
.
tables
where
1
=
0
;
grant
select
on
pg_catalog
.
pg_attrdef
to
public
;
...
...
@@ -179,7 +186,7 @@ and t.table_name = c.table_name
and
t
.
table_schema
=
c
.
table_schema
;
grant
select
on
pg_catalog
.
pg_attribute
to
public
;
create
view
pg_catalog
.
pg_index
-- (oid, indexrelid, indrelid, indisclustered, indisunique, indisprimary, indexprs, indkey)
create
view
pg_catalog
.
pg_index
-- (oid, indexrelid, indrelid, indisclustered, indisunique, indisprimary, indexprs, indkey
, indpred
)
as
select
i
.
id
oid
,
...
...
@@ -189,7 +196,8 @@ select
not
non_unique
indisunique
,
primary_key
indisprimary
,
cast
(
''
as
varchar_ignorecase
)
indexprs
,
cast
(
1
as
array
)
indkey
cast
(
1
as
array
)
indkey
,
null
indpred
from
information_schema
.
indexes
i
,
information_schema
.
tables
t
where
i
.
table_schema
=
t
.
table_schema
and
i
.
table_name
=
t
.
table_name
...
...
@@ -201,6 +209,12 @@ grant select on pg_catalog.pg_index to public;
drop
alias
if
exists
pg_get_indexdef
;
create
alias
pg_get_indexdef
for
"org.h2.server.pg.PgServer.getIndexColumn"
;
drop
alias
if
exists
pg_catalog
.
pg_get_indexdef
;
create
alias
pg_catalog
.
pg_get_indexdef
for
"org.h2.server.pg.PgServer.getIndexColumn"
;
drop
alias
if
exists
pg_catalog
.
pg_get_expr
;
create
alias
pg_catalog
.
pg_get_expr
for
"org.h2.server.pg.PgServer.getPgExpr"
;
drop
alias
if
exists
version
;
create
alias
version
for
"org.h2.server.pg.PgServer.getVersion"
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论