Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
641b658c
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,发现更多精彩内容 >>
提交
641b658c
编写于
10月 23, 2002
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Page \h output and centralize psql paging code in PageOutput().
上级
30963fc2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
86 addition
and
99 deletion
+86
-99
src/bin/psql/command.c
src/bin/psql/command.c
+3
-2
src/bin/psql/common.c
src/bin/psql/common.c
+44
-1
src/bin/psql/common.h
src/bin/psql/common.h
+3
-1
src/bin/psql/help.c
src/bin/psql/help.c
+23
-49
src/bin/psql/help.h
src/bin/psql/help.h
+2
-2
src/bin/psql/print.c
src/bin/psql/print.c
+11
-44
未找到文件。
src/bin/psql/command.c
浏览文件 @
641b658c
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.8
3 2002/10/15 02:24:15 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.8
4 2002/10/23 19:23:56 momjian
Exp $
*/
#include "postgres_fe.h"
#include "command.h"
...
...
@@ -493,7 +493,8 @@ exec_command(const char *cmd,
/* help */
else
if
(
strcmp
(
cmd
,
"h"
)
==
0
||
strcmp
(
cmd
,
"help"
)
==
0
)
{
helpSQL
(
options_string
?
&
options_string
[
strspn
(
options_string
,
"
\t\n\r
"
)]
:
NULL
);
helpSQL
(
options_string
?
&
options_string
[
strspn
(
options_string
,
"
\t\n\r
"
)]
:
NULL
,
pset
.
popt
.
topt
.
pager
);
/* set pointer to end of line */
if
(
string
)
string
+=
strlen
(
string
);
...
...
src/bin/psql/common.c
浏览文件 @
641b658c
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.4
8 2002/10/15 16:44:21 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.4
9 2002/10/23 19:23:56 momjian
Exp $
*/
#include "postgres_fe.h"
...
...
@@ -515,3 +515,46 @@ SendQuery(const char *query)
return
success
;
}
/*
* PageOutput
*
* Tests if pager is needed and returns appropriate FILE pointer.
*/
FILE
*
PageOutput
(
int
lines
,
bool
pager
)
{
/* check whether we need / can / are supposed to use pager */
if
(
pager
#ifndef WIN32
&&
isatty
(
fileno
(
stdin
))
&&
isatty
(
fileno
(
stdout
))
#endif
)
{
const
char
*
pagerprog
;
#ifdef TIOCGWINSZ
int
result
;
struct
winsize
screen_size
;
result
=
ioctl
(
fileno
(
stdout
),
TIOCGWINSZ
,
&
screen_size
);
if
(
result
==
-
1
||
lines
>
screen_size
.
ws_row
)
{
#endif
pagerprog
=
getenv
(
"PAGER"
);
if
(
!
pagerprog
)
pagerprog
=
DEFAULT_PAGER
;
#ifndef WIN32
pqsignal
(
SIGPIPE
,
SIG_IGN
);
#endif
return
popen
(
pagerprog
,
"w"
);
#ifdef TIOCGWINSZ
}
#endif
}
return
stdout
;
}
src/bin/psql/common.h
浏览文件 @
641b658c
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.
19 2002/10/15 02:24:16 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.
20 2002/10/23 19:23:56 momjian
Exp $
*/
#ifndef COMMON_H
#define COMMON_H
...
...
@@ -37,6 +37,8 @@ extern PGresult *PSQLexec(const char *query, bool ignore_command_ok);
extern
bool
SendQuery
(
const
char
*
query
);
extern
FILE
*
PageOutput
(
int
lines
,
bool
pager
);
/* sprompt.h */
extern
char
*
simple_prompt
(
const
char
*
prompt
,
int
maxlen
,
bool
echo
);
...
...
src/bin/psql/help.c
浏览文件 @
641b658c
...
...
@@ -3,9 +3,10 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.5
8 2002/10/18 22:05:36 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.5
9 2002/10/23 19:23:56 momjian
Exp $
*/
#include "postgres_fe.h"
#include "common.h"
#include "print.h"
#include "help.h"
...
...
@@ -161,48 +162,11 @@ struct winsize
void
slashUsage
(
bool
pager
)
{
FILE
*
output
,
*
pagerfd
=
NULL
;
/* check whether we need / can / are supposed to use pager */
if
(
pager
#ifndef WIN32
&&
isatty
(
fileno
(
stdin
))
&&
isatty
(
fileno
(
stdout
))
#endif
)
{
const
char
*
pagerprog
;
FILE
*
output
;
#ifdef TIOCGWINSZ
int
result
;
struct
winsize
screen_size
;
output
=
PageOutput
(
50
,
pager
);
result
=
ioctl
(
fileno
(
stdout
),
TIOCGWINSZ
,
&
screen_size
);
if
(
result
==
-
1
||
50
>
screen_size
.
ws_row
)
{
#endif
pagerprog
=
getenv
(
"PAGER"
);
if
(
!
pagerprog
)
pagerprog
=
DEFAULT_PAGER
;
pagerfd
=
popen
(
pagerprog
,
"w"
);
#ifdef TIOCGWINSZ
}
#endif
}
if
(
pagerfd
)
{
output
=
pagerfd
;
#ifndef WIN32
pqsignal
(
SIGPIPE
,
SIG_IGN
);
#endif
}
else
output
=
stdout
;
/* if you add/remove a line here, change the row test above */
/* if you add/remove a line here, change the row count above */
/*
* if this " is the start of the string then it ought to end there to
...
...
@@ -262,9 +226,9 @@ slashUsage(bool pager)
fprintf
(
output
,
_
(
"
\\
z [PATTERN] list table access privileges (same as
\\
dp)
\n
"
));
fprintf
(
output
,
_
(
"
\\
! [COMMAND] execute command in shell or start interactive shell
\n
"
));
if
(
pagerfd
)
if
(
output
!=
stdout
)
{
pclose
(
pagerfd
);
pclose
(
output
);
#ifndef WIN32
pqsignal
(
SIGPIPE
,
SIG_DFL
);
#endif
...
...
@@ -278,7 +242,7 @@ slashUsage(bool pager)
*
*/
void
helpSQL
(
const
char
*
topic
)
helpSQL
(
const
char
*
topic
,
bool
pager
)
{
#define VALUE_OR_NULL(a) ((a) ? (a) : "")
...
...
@@ -286,21 +250,31 @@ helpSQL(const char *topic)
{
int
i
;
int
items_per_column
=
(
QL_HELP_COUNT
+
2
)
/
3
;
FILE
*
output
;
output
=
PageOutput
(
items_per_column
,
pager
);
puts
(
_
(
"Available help:"
)
);
fputs
(
_
(
"Available help:
\n
"
),
output
);
for
(
i
=
0
;
i
<
items_per_column
;
i
++
)
{
printf
(
" %-26s%-26s"
,
fprintf
(
output
,
" %-26s%-26s"
,
VALUE_OR_NULL
(
QL_HELP
[
i
].
cmd
),
VALUE_OR_NULL
(
QL_HELP
[
i
+
items_per_column
].
cmd
));
if
(
i
+
2
*
items_per_column
<
QL_HELP_COUNT
)
printf
(
"%-26s"
,
fprintf
(
output
,
"%-26s"
,
VALUE_OR_NULL
(
QL_HELP
[
i
+
2
*
items_per_column
].
cmd
));
fputc
(
'\n'
,
stdout
);
fputc
(
'\n'
,
output
);
}
/* Only close if we used the pager */
if
(
output
!=
stdout
)
{
pclose
(
output
);
#ifndef WIN32
pqsignal
(
SIGPIPE
,
SIG_DFL
);
#endif
}
}
else
{
int
i
;
...
...
src/bin/psql/help.h
浏览文件 @
641b658c
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.
9 2002/07/15 01:56:25
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.
10 2002/10/23 19:23:57
momjian Exp $
*/
#ifndef HELP_H
#define HELP_H
...
...
@@ -12,7 +12,7 @@ void usage(void);
void
slashUsage
(
bool
pager
);
void
helpSQL
(
const
char
*
topic
);
void
helpSQL
(
const
char
*
topic
,
bool
pager
);
void
print_copyright
(
void
);
...
...
src/bin/psql/print.c
浏览文件 @
641b658c
...
...
@@ -3,9 +3,10 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.3
2 2002/10/03 17:09:42
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.3
3 2002/10/23 19:23:57
momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
#include "print.h"
#include <math.h>
...
...
@@ -970,9 +971,7 @@ printTable(const char *title,
{
const
char
*
default_footer
[]
=
{
NULL
};
unsigned
short
int
border
=
opt
->
border
;
FILE
*
pagerfd
=
NULL
,
*
output
;
FILE
*
output
;
if
(
opt
->
format
==
PRINT_NOTHING
)
return
;
...
...
@@ -983,25 +982,12 @@ printTable(const char *title,
if
(
opt
->
format
!=
PRINT_HTML
&&
border
>
2
)
border
=
2
;
/* check whether we need / can / are supposed to use pager */
if
(
fout
==
stdout
&&
opt
->
pager
#ifndef WIN32
&&
isatty
(
fileno
(
stdin
))
&&
isatty
(
fileno
(
stdout
))
#endif
)
if
(
fout
==
stdout
)
{
const
char
*
pagerprog
;
#ifdef TIOCGWINSZ
unsigned
int
col_count
=
0
,
row_count
=
0
,
lines
;
int
col_count
=
0
,
row_count
=
0
,
lines
;
const
char
*
const
*
ptr
;
int
result
;
struct
winsize
screen_size
;
/* rough estimate of columns and rows */
if
(
headers
)
...
...
@@ -1020,31 +1006,11 @@ printTable(const char *title,
if
(
footers
&&
!
opt
->
tuples_only
)
for
(
ptr
=
footers
;
*
ptr
;
ptr
++
)
lines
++
;
result
=
ioctl
(
fileno
(
stdout
),
TIOCGWINSZ
,
&
screen_size
);
if
(
result
==
-
1
||
lines
>
screen_size
.
ws_row
)
{
#endif
pagerprog
=
getenv
(
"PAGER"
);
if
(
!
pagerprog
)
pagerprog
=
DEFAULT_PAGER
;
pagerfd
=
popen
(
pagerprog
,
"w"
);
#ifdef TIOCGWINSZ
}
#endif
}
if
(
pagerfd
)
{
output
=
pagerfd
;
#ifndef WIN32
pqsignal
(
SIGPIPE
,
SIG_IGN
);
#endif
output
=
PageOutput
(
lines
,
opt
->
pager
);
}
else
output
=
fout
;
/* print the stuff */
switch
(
opt
->
format
)
...
...
@@ -1077,9 +1043,10 @@ printTable(const char *title,
fprintf
(
stderr
,
"+ Oops, you shouldn't see this!
\n
"
);
}
if
(
pagerfd
)
/* Only close if we used the pager */
if
(
fout
==
stdout
&&
output
!=
stdout
)
{
pclose
(
pagerfd
);
pclose
(
output
);
#ifndef WIN32
pqsignal
(
SIGPIPE
,
SIG_DFL
);
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录