Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
40cad8b6
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40cad8b6
编写于
4月 25, 1999
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
My first cut at libpq revision didn't handle MULTIBYTE correctly,
but I think it's OK now...
上级
fad6f292
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
78 deletion
+53
-78
src/backend/access/common/printtup.c
src/backend/access/common/printtup.c
+4
-23
src/backend/commands/async.c
src/backend/commands/async.c
+2
-2
src/backend/libpq/pqformat.c
src/backend/libpq/pqformat.c
+42
-46
src/backend/tcop/dest.c
src/backend/tcop/dest.c
+2
-3
src/include/libpq/pqformat.h
src/include/libpq/pqformat.h
+3
-4
未找到文件。
src/backend/access/common/printtup.c
浏览文件 @
40cad8b6
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.4
3 1999/04/25 03:19:2
3 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.4
4 1999/04/25 19:27:4
3 tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -25,10 +25,6 @@
#include "libpq/pqformat.h"
#include "utils/syscache.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
static
void
printtup_setup
(
DestReceiver
*
self
,
TupleDesc
typeinfo
);
static
void
printtup
(
HeapTuple
tuple
,
TupleDesc
typeinfo
,
DestReceiver
*
self
);
static
void
printtup_cleanup
(
DestReceiver
*
self
);
...
...
@@ -157,14 +153,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
StringInfoData
buf
;
int
i
,
j
,
k
,
outputlen
;
k
;
char
*
outputstr
;
Datum
attr
;
bool
isnull
;
#ifdef MULTIBYTE
unsigned
char
*
p
;
#endif
/* Set or update my derived attribute info, if needed */
if
(
myState
->
attrinfo
!=
typeinfo
||
...
...
@@ -213,24 +205,13 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
{
outputstr
=
(
char
*
)
(
*
fmgr_faddr
(
&
thisState
->
finfo
))
(
attr
,
thisState
->
typelem
,
typeinfo
->
attrs
[
i
]
->
atttypmod
);
#ifdef MULTIBYTE
p
=
pg_server_to_client
(
outputstr
,
strlen
(
outputstr
));
outputlen
=
strlen
(
p
);
pq_sendint
(
&
buf
,
outputlen
+
VARHDRSZ
,
VARHDRSZ
);
pq_sendbytes
(
&
buf
,
p
,
outputlen
);
#else
outputlen
=
strlen
(
outputstr
);
pq_sendint
(
&
buf
,
outputlen
+
VARHDRSZ
,
VARHDRSZ
);
pq_sendbytes
(
&
buf
,
outputstr
,
outputlen
);
#endif
pq_sendcountedtext
(
&
buf
,
outputstr
,
strlen
(
outputstr
));
pfree
(
outputstr
);
}
else
{
outputstr
=
"<unprintable>"
;
outputlen
=
strlen
(
outputstr
);
pq_sendint
(
&
buf
,
outputlen
+
VARHDRSZ
,
VARHDRSZ
);
pq_sendbytes
(
&
buf
,
outputstr
,
outputlen
);
pq_sendcountedtext
(
&
buf
,
outputstr
,
strlen
(
outputstr
));
}
}
...
...
src/backend/commands/async.c
浏览文件 @
40cad8b6
...
...
@@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.4
5 1999/04/25 03:19:08
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.4
6 1999/04/25 19:27:43
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -803,7 +803,7 @@ NotifyMyFrontEnd(char *relname, int32 listenerPID)
pq_beginmessage
(
&
buf
);
pq_sendbyte
(
&
buf
,
'A'
);
pq_sendint
(
&
buf
,
listenerPID
,
sizeof
(
int32
));
pq_sendstring
(
&
buf
,
relname
,
strlen
(
relname
)
);
pq_sendstring
(
&
buf
,
relname
);
pq_endmessage
(
&
buf
);
/* NOTE: we do not do pq_flush() here. For a self-notify, it will
* happen at the end of the transaction, and for incoming notifies
...
...
src/backend/libpq/pqformat.c
浏览文件 @
40cad8b6
...
...
@@ -15,7 +15,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqformat.c,v 1.
1 1999/04/25 03:19:22
tgl Exp $
* $Id: pqformat.c,v 1.
2 1999/04/25 19:27:44
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -26,7 +26,7 @@
* pq_sendbyte - append a raw byte to a StringInfo buffer
* pq_sendint - append a binary integer to a StringInfo buffer
* pq_sendbytes - append raw data to a StringInfo buffer
* pq_send
text
- append a text string (with MULTIBYTE conversion)
* pq_send
countedtext
- append a text string (with MULTIBYTE conversion)
* pq_sendstring - append a null-terminated text string (with MULTIBYTE)
* pq_endmessage - send the completed message to the frontend
* Note: it is also possible to append data to the StringInfo buffer using
...
...
@@ -36,9 +36,8 @@
* Message input:
* pq_getint - get an integer from connection
* pq_getstr - get a null terminated string from connection
* pq_getnchar - get n characters from connection, and null-terminate
* pq_getstr and pq_getnchar perform MULTIBYTE conversion on the collected
* string. Use the raw pqcomm.c routines pq_getstring and pq_getbytes
* pq_getstr performs MULTIBYTE conversion on the collected string.
* Use the raw pqcomm.c routines pq_getstring or pq_getbytes
* to fetch data without conversion.
*/
#include "postgres.h"
...
...
@@ -48,6 +47,7 @@
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
#include <string.h>
#ifdef HAVE_ENDIAN_H
#include <endian.h>
#endif
...
...
@@ -110,36 +110,49 @@ pq_sendbytes(StringInfo buf, const char *data, int datalen)
}
/* --------------------------------
* pq_send
text
- append a text string (with MULTIBYTE conversion)
* pq_send
countedtext
- append a text string (with MULTIBYTE conversion)
*
*
NB: passed text string must be null-terminated, even though we expect
*
the caller to hand us the length (this is just because the caller
*
usually knows the length anyway). In this routine, the data sent to
* t
he frontend is NOT null-terminated
.
*
The data sent to the frontend by this routine is a 4-byte count field
*
(the count includes itself, by convention) followed by the string.
*
The passed text string need not be null-terminated, and the data sent
* t
o the frontend isn't either
.
* --------------------------------
*/
void
pq_sendtext
(
StringInfo
buf
,
const
char
*
str
,
int
slen
)
pq_send
counted
text
(
StringInfo
buf
,
const
char
*
str
,
int
slen
)
{
#ifdef MULTIBYTE
str
=
(
const
char
*
)
pg_server_to_client
(
str
,
slen
);
const
char
*
p
;
p
=
(
const
char
*
)
pg_server_to_client
((
unsigned
char
*
)
str
,
slen
);
if
(
p
!=
str
)
/* actual conversion has been done? */
{
str
=
p
;
slen
=
strlen
(
str
);
}
#endif
pq_sendint
(
buf
,
slen
+
4
,
4
);
appendBinaryStringInfo
(
buf
,
str
,
slen
);
}
/* --------------------------------
* pq_sendstring - append a null-terminated text string (with MULTIBYTE)
*
* NB: passed text string must be null-terminated, even though we expect
* the caller to hand us the length (this is just because the caller
* usually knows the length anyway).
* NB: passed text string must be null-terminated, and so is the data
* sent to the frontend.
* --------------------------------
*/
void
pq_sendstring
(
StringInfo
buf
,
const
char
*
str
,
int
slen
)
pq_sendstring
(
StringInfo
buf
,
const
char
*
str
)
{
int
slen
=
strlen
(
str
);
#ifdef MULTIBYTE
str
=
(
const
char
*
)
pg_server_to_client
(
str
,
slen
);
const
char
*
p
;
p
=
(
const
char
*
)
pg_server_to_client
((
unsigned
char
*
)
str
,
slen
);
if
(
p
!=
str
)
/* actual conversion has been done? */
{
str
=
p
;
slen
=
strlen
(
str
);
}
#endif
appendBinaryStringInfo
(
buf
,
str
,
slen
+
1
);
}
...
...
@@ -258,35 +271,18 @@ pq_getstr(char *s, int maxlen)
c
=
pq_getstring
(
s
,
maxlen
);
#ifdef MULTIBYTE
p
=
(
char
*
)
pg_client_to_server
((
unsigned
char
*
)
s
,
maxlen
);
if
(
s
!=
p
)
/* actual conversion has been done? */
strcpy
(
s
,
p
);
#endif
return
c
;
}
/* --------------------------------
* pq_getnchar - get n characters from connection, and null-terminate
*
* returns 0 if OK, EOF if trouble
* --------------------------------
*/
int
pq_getnchar
(
char
*
s
,
int
len
)
{
int
c
;
#ifdef MULTIBYTE
char
*
p
;
#endif
c
=
pq_getbytes
(
s
,
len
);
s
[
len
]
=
'\0'
;
#ifdef MULTIBYTE
p
=
(
char
*
)
pg_client_to_server
((
unsigned
char
*
)
s
,
len
+
1
);
if
(
s
!=
p
)
/* actual conversion has been done? */
strcpy
(
s
,
p
);
p
=
(
char
*
)
pg_client_to_server
((
unsigned
char
*
)
s
,
strlen
(
s
));
if
(
p
!=
s
)
/* actual conversion has been done? */
{
int
newlen
=
strlen
(
p
);
if
(
newlen
<
maxlen
)
strcpy
(
s
,
p
);
else
{
strncpy
(
s
,
p
,
maxlen
);
s
[
maxlen
-
1
]
=
'\0'
;
}
}
#endif
return
c
;
...
...
src/backend/tcop/dest.c
浏览文件 @
40cad8b6
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.2
6 1999/04/25 03:19:09
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.2
7 1999/04/25 19:27:45
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -155,8 +155,7 @@ BeginCommand(char *pname,
for
(
i
=
0
;
i
<
natts
;
++
i
)
{
pq_sendstring
(
&
buf
,
attrs
[
i
]
->
attname
.
data
,
strlen
(
attrs
[
i
]
->
attname
.
data
));
pq_sendstring
(
&
buf
,
attrs
[
i
]
->
attname
.
data
);
pq_sendint
(
&
buf
,
(
int
)
attrs
[
i
]
->
atttypid
,
sizeof
(
attrs
[
i
]
->
atttypid
));
pq_sendint
(
&
buf
,
attrs
[
i
]
->
attlen
,
...
...
src/include/libpq/pqformat.h
浏览文件 @
40cad8b6
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqformat.h,v 1.
1 1999/04/25 03:19:14
tgl Exp $
* $Id: pqformat.h,v 1.
2 1999/04/25 19:27:47
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -19,13 +19,12 @@
extern
void
pq_sendbyte
(
StringInfo
buf
,
int
byt
);
extern
void
pq_sendbytes
(
StringInfo
buf
,
const
char
*
data
,
int
datalen
);
extern
void
pq_sendtext
(
StringInfo
buf
,
const
char
*
str
,
int
slen
);
extern
void
pq_sendstring
(
StringInfo
buf
,
const
char
*
str
,
int
slen
);
extern
void
pq_send
counted
text
(
StringInfo
buf
,
const
char
*
str
,
int
slen
);
extern
void
pq_sendstring
(
StringInfo
buf
,
const
char
*
str
);
extern
void
pq_sendint
(
StringInfo
buf
,
int
i
,
int
b
);
extern
void
pq_endmessage
(
StringInfo
buf
);
extern
int
pq_getint
(
int
*
result
,
int
b
);
extern
int
pq_getstr
(
char
*
s
,
int
maxlen
);
extern
int
pq_getnchar
(
char
*
s
,
int
len
);
#endif
/* PQFORMAT_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录