Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
e25e6a6d
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,发现更多精彩内容 >>
提交
e25e6a6d
编写于
8月 31, 1999
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Commit the bulk of Mike Ansley's long-query changes in the
backend. Still much left to do.
上级
ab5cafa5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
67 addition
and
109 deletion
+67
-109
src/backend/libpq/pqcomm.c
src/backend/libpq/pqcomm.c
+10
-16
src/backend/libpq/pqformat.c
src/backend/libpq/pqformat.c
+11
-18
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+40
-65
src/include/libpq/libpq.h
src/include/libpq/libpq.h
+3
-2
src/include/libpq/pqcomm.h
src/include/libpq/pqcomm.h
+1
-6
src/include/libpq/pqformat.h
src/include/libpq/pqformat.h
+2
-2
未找到文件。
src/backend/libpq/pqcomm.c
浏览文件 @
e25e6a6d
...
...
@@ -28,7 +28,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.c,v 1.8
1 1999/07/23 03:00:10
tgl Exp $
* $Id: pqcomm.c,v 1.8
2 1999/08/31 04:26:37
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -526,38 +526,32 @@ pq_getbytes(char *s, size_t len)
/* --------------------------------
* pq_getstring - get a null terminated string from connection
*
* The return value is placed in an expansible StringInfo.
* Note that space allocation comes from the current memory context!
*
* NOTE: this routine does not do any MULTIBYTE conversion,
* even though it is presumably useful only for text, because
* no code in this module should depend on MULTIBYTE mode.
* See pq_getstr in pqformat.c for that.
*
* FIXME: we ought to use an expansible StringInfo buffer,
* rather than dropping data if the message is too long.
*
* returns 0 if OK, EOF if trouble
* --------------------------------
*/
int
pq_getstring
(
char
*
s
,
size_t
len
)
pq_getstring
(
StringInfo
s
)
{
int
c
;
/*
* Keep on reading until we get the terminating '\0', discarding any
* bytes we don't have room for.
*/
/* Reset string to empty */
s
->
len
=
0
;
s
->
data
[
0
]
=
'\0'
;
/* Read until we get the terminating '\0' */
while
((
c
=
pq_getbyte
())
!=
EOF
&&
c
!=
'\0'
)
{
if
(
len
>
1
)
{
*
s
++
=
c
;
len
--
;
}
appendStringInfoChar
(
s
,
c
);
}
*
s
=
'\0'
;
if
(
c
==
EOF
)
return
EOF
;
...
...
src/backend/libpq/pqformat.c
浏览文件 @
e25e6a6d
...
...
@@ -15,7 +15,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqformat.c,v 1.
7 1999/07/17 20:17:03 momjian
Exp $
* $Id: pqformat.c,v 1.
8 1999/08/31 04:26:37 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -290,37 +290,30 @@ pq_getint(int *result, int b)
/* --------------------------------
* pq_getstr - get a null terminated string from connection
*
*
FIXME: we ought to use an expansible StringInfo buffer,
*
rather than dropping data if the message is too long.
*
The return value is placed in an expansible StringInfo.
*
Note that space allocation comes from the current memory context!
*
* returns 0 if OK, EOF if trouble
* --------------------------------
*/
int
pq_getstr
(
char
*
s
,
int
maxlen
)
pq_getstr
(
StringInfo
s
)
{
int
c
;
#ifdef MULTIBYTE
char
*
p
;
#endif
c
=
pq_getstring
(
s
,
maxlen
);
c
=
pq_getstring
(
s
);
#ifdef MULTIBYTE
p
=
(
char
*
)
pg_client_to_server
((
unsigned
char
*
)
s
,
strlen
(
s
)
);
if
(
p
!=
s
)
/* actual conversion has been done? */
p
=
(
char
*
)
pg_client_to_server
((
unsigned
char
*
)
s
->
data
,
s
->
len
);
if
(
p
!=
s
->
data
)
/* actual conversion has been done? */
{
int
newlen
=
strlen
(
p
);
if
(
newlen
<
maxlen
)
strcpy
(
s
,
p
);
else
{
strncpy
(
s
,
p
,
maxlen
);
s
[
maxlen
-
1
]
=
'\0'
;
}
/* reset s to empty, and append the new string p */
s
->
len
=
0
;
s
->
data
[
0
]
=
'\0'
;
appendBinaryStringInfo
(
s
,
p
,
strlen
(
p
));
}
#endif
...
...
src/backend/tcop/postgres.c
浏览文件 @
e25e6a6d
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.12
7 1999/07/22 02:40:07
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.12
8 1999/08/31 04:26:40
tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
...
...
@@ -158,9 +158,9 @@ int _exec_repeat_ = 1;
* decls for routines only used in this file
* ----------------------------------------------------------------
*/
static
int
InteractiveBackend
(
char
*
inBuf
);
static
int
SocketBackend
(
char
*
inBuf
);
static
int
ReadCommand
(
char
*
inBuf
);
static
int
InteractiveBackend
(
StringInfo
inBuf
);
static
int
SocketBackend
(
StringInfo
inBuf
);
static
int
ReadCommand
(
StringInfo
inBuf
);
static
void
pg_exec_query
(
char
*
query_string
);
...
...
@@ -178,9 +178,8 @@ static void pg_exec_query(char *query_string);
*/
static
int
InteractiveBackend
(
char
*
inBuf
)
InteractiveBackend
(
StringInfo
inBuf
)
{
char
*
stuff
=
inBuf
;
/* current place in input buffer */
int
c
;
/* character read from getc() */
bool
end
=
false
;
/* end-of-input flag */
bool
backslashSeen
=
false
;
/* have we seen a \ ? */
...
...
@@ -192,6 +191,10 @@ InteractiveBackend(char *inBuf)
printf
(
"backend> "
);
fflush
(
stdout
);
/* Reset inBuf to empty */
inBuf
->
len
=
0
;
inBuf
->
data
[
0
]
=
'\0'
;
for
(;;)
{
if
(
UseNewLine
)
...
...
@@ -207,14 +210,15 @@ InteractiveBackend(char *inBuf)
{
if
(
backslashSeen
)
{
stuff
--
;
/* discard backslash from inBuf */
inBuf
->
data
[
--
inBuf
->
len
]
=
'\0'
;
backslashSeen
=
false
;
continue
;
}
else
{
/* keep the newline character */
*
stuff
++
=
'\n'
;
*
stuff
++
=
'\0'
;
appendStringInfoChar
(
inBuf
,
'\n'
);
break
;
}
}
...
...
@@ -223,7 +227,7 @@ InteractiveBackend(char *inBuf)
else
backslashSeen
=
false
;
*
stuff
++
=
(
char
)
c
;
appendStringInfoChar
(
inBuf
,
(
char
)
c
)
;
}
if
(
c
==
EOF
)
...
...
@@ -236,9 +240,9 @@ InteractiveBackend(char *inBuf)
* ----------------
*/
while
((
c
=
getc
(
stdin
))
!=
EOF
)
*
stuff
++
=
(
char
)
c
;
appendStringInfoChar
(
inBuf
,
(
char
)
c
)
;
if
(
stuff
==
inBuf
)
if
(
inBuf
->
len
==
0
)
end
=
true
;
}
...
...
@@ -261,7 +265,7 @@ InteractiveBackend(char *inBuf)
* ----------------
*/
if
(
EchoQuery
)
printf
(
"query: %s
\n
"
,
inBuf
);
printf
(
"query: %s
\n
"
,
inBuf
->
data
);
fflush
(
stdout
);
return
'Q'
;
...
...
@@ -274,7 +278,7 @@ InteractiveBackend(char *inBuf)
* the user is placed in its parameter inBuf.
*
* If the input is a fastpath function call (case 'F') then
* the function call is processed in HandleFunctionRequest()
.
* the function call is processed in HandleFunctionRequest()
* (now called from PostgresMain()).
*
* EOF is returned if the connection is lost.
...
...
@@ -282,7 +286,7 @@ InteractiveBackend(char *inBuf)
*/
static
int
SocketBackend
(
char
*
inBuf
)
SocketBackend
(
StringInfo
inBuf
)
{
char
qtype
;
char
result
=
'\0'
;
...
...
@@ -302,7 +306,7 @@ SocketBackend(char *inBuf)
* ----------------
*/
case
'Q'
:
if
(
pq_getstr
(
inBuf
,
MAX_PARSE_BUFFER
))
if
(
pq_getstr
(
inBuf
))
return
EOF
;
result
=
'Q'
;
break
;
...
...
@@ -312,7 +316,7 @@ SocketBackend(char *inBuf)
* ----------------
*/
case
'F'
:
if
(
pq_getstr
(
inBuf
,
MAX_PARSE_BUFFER
))
if
(
pq_getstr
(
inBuf
))
return
EOF
;
/* ignore "string" at start of F message */
result
=
'F'
;
break
;
...
...
@@ -347,12 +351,21 @@ SocketBackend(char *inBuf)
* ----------------
*/
static
int
ReadCommand
(
char
*
inBuf
)
ReadCommand
(
StringInfo
inBuf
)
{
MemoryContext
oldcontext
;
int
result
;
/* Make sure any expansion of inBuf happens in permanent memory context,
* so that we can keep using it for future command cycles.
*/
oldcontext
=
MemoryContextSwitchTo
(
TopMemoryContext
);
if
(
IsUnderPostmaster
)
re
turn
SocketBackend
(
inBuf
);
re
sult
=
SocketBackend
(
inBuf
);
else
return
InteractiveBackend
(
inBuf
);
result
=
InteractiveBackend
(
inBuf
);
MemoryContextSwitchTo
(
oldcontext
);
return
result
;
}
List
*
...
...
@@ -374,45 +387,7 @@ pg_parse_and_plan(char *query_string, /* string to execute */
if
(
DebugPrintQuery
)
{
if
(
DebugPrintQuery
>
3
)
{
/* Print the query string as is if query debug level > 3 */
TPRINTF
(
TRACE_QUERY
,
"query: %s"
,
query_string
);
}
else
{
/* Print condensed query string to fit in one log line */
char
buff
[
MAX_QUERY_SIZE
+
1
];
char
c
,
*
s
,
*
d
;
int
n
,
is_space
=
1
;
for
(
s
=
query_string
,
d
=
buff
,
n
=
0
;
(
c
=
*
s
)
&&
(
n
<
MAX_QUERY_SIZE
);
s
++
)
{
switch
(
c
)
{
case
'\r'
:
case
'\n'
:
case
'\t'
:
c
=
' '
;
/* fall through */
case
' '
:
if
(
is_space
)
continue
;
is_space
=
1
;
break
;
default:
is_space
=
0
;
break
;
}
*
d
++
=
c
;
n
++
;
}
*
d
=
'\0'
;
TPRINTF
(
TRACE_QUERY
,
"query: %s"
,
buff
);
}
TPRINTF
(
TRACE_QUERY
,
"query: %s"
,
query_string
);
}
/* ----------------
...
...
@@ -889,7 +864,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
int
errs
=
0
;
int
firstchar
;
char
parser_input
[
MAX_PARSE_BUFFER
]
;
StringInfo
parser_input
;
char
*
userName
;
/* Used if verbose is set, must be initialized */
...
...
@@ -1452,6 +1427,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
on_shmem_exit
(
remove_all_temp_relations
,
NULL
);
parser_input
=
makeStringInfo
();
/* initialize input buffer */
/* ----------------
* Set up handler for cancel-request signal, and
* send this backend's cancellation info to the frontend.
...
...
@@ -1492,7 +1469,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if
(
!
IsUnderPostmaster
)
{
puts
(
"
\n
POSTGRES backend interactive interface "
);
puts
(
"$Revision: 1.12
7 $ $Date: 1999/07/22 02:40:07
$
\n
"
);
puts
(
"$Revision: 1.12
8 $ $Date: 1999/08/31 04:26:40
$
\n
"
);
}
/* ----------------
...
...
@@ -1548,8 +1525,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* (3) read a command.
* ----------------
*/
MemSet
(
parser_input
,
0
,
MAX_PARSE_BUFFER
);
firstchar
=
ReadCommand
(
parser_input
);
QueryCancel
=
false
;
/* forget any earlier CANCEL signal */
...
...
@@ -1592,7 +1567,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* ----------------
*/
case
'Q'
:
if
(
strspn
(
parser_input
,
"
\t\n
"
)
==
strlen
(
parser_input
)
)
if
(
strspn
(
parser_input
->
data
,
"
\t\n
"
)
==
parser_input
->
len
)
{
/* ----------------
* if there is nothing in the input buffer, don't bother
...
...
@@ -1616,7 +1591,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
TPRINTF
(
TRACE_VERBOSE
,
"StartTransactionCommand"
);
StartTransactionCommand
();
pg_exec_query
(
parser_input
);
pg_exec_query
(
parser_input
->
data
);
if
(
ShowStats
)
ShowUsage
();
...
...
src/include/libpq/libpq.h
浏览文件 @
e25e6a6d
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq.h,v 1.3
2 1999/07/15 15:21:15 momjian
Exp $
* $Id: libpq.h,v 1.3
3 1999/08/31 04:26:33 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -17,6 +17,7 @@
#include <netinet/in.h>
#include "lib/stringinfo.h"
#include "libpq/libpq-be.h"
#include "tcop/dest.h"
#include "utils/exc.h"
...
...
@@ -241,7 +242,7 @@ extern void pq_init(void);
extern
int
pq_getport
(
void
);
extern
void
pq_close
(
void
);
extern
int
pq_getbytes
(
char
*
s
,
size_t
len
);
extern
int
pq_getstring
(
char
*
s
,
size_t
len
);
extern
int
pq_getstring
(
StringInfo
s
);
extern
int
pq_peekbyte
(
void
);
extern
int
pq_putbytes
(
const
char
*
s
,
size_t
len
);
extern
int
pq_flush
(
void
);
...
...
src/include/libpq/pqcomm.h
浏览文件 @
e25e6a6d
...
...
@@ -8,7 +8,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.h,v 1.3
8 1999/07/17 20:18:29 momjian
Exp $
* $Id: pqcomm.h,v 1.3
9 1999/08/31 04:26:33 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -26,11 +26,6 @@
#include <netinet/in.h>
#endif
/*
* Internal send/receive buffers in libpq.
*/
#define PQ_BUFFER_SIZE 8192
/* Define a generic socket address type. */
typedef
union
SockAddr
...
...
src/include/libpq/pqformat.h
浏览文件 @
e25e6a6d
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqformat.h,v 1.
5 1999/07/15 15:21:16 momjian
Exp $
* $Id: pqformat.h,v 1.
6 1999/08/31 04:26:33 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -26,6 +26,6 @@ extern void pq_endmessage(StringInfo buf);
extern
int
pq_puttextmessage
(
char
msgtype
,
const
char
*
str
);
extern
int
pq_getint
(
int
*
result
,
int
b
);
extern
int
pq_getstr
(
char
*
s
,
int
maxlen
);
extern
int
pq_getstr
(
StringInfo
s
);
#endif
/* PQFORMAT_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录