Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
5adf98ae
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,发现更多精彩内容 >>
提交
5adf98ae
编写于
5月 08, 2008
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add psql '\pset format wrapped' mode to wrap output to screen width, or
file/pipe output too if \pset columns' is set. Bryce Nesbitt
上级
eb915caf
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
445 addition
and
198 deletion
+445
-198
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+41
-4
src/bin/psql/command.c
src/bin/psql/command.c
+17
-2
src/bin/psql/mbprint.c
src/bin/psql/mbprint.c
+16
-9
src/bin/psql/print.c
src/bin/psql/print.c
+364
-181
src/bin/psql/print.h
src/bin/psql/print.h
+4
-1
src/bin/psql/startup.c
src/bin/psql/startup.c
+3
-1
未找到文件。
doc/src/sgml/ref/psql-ref.sgml
浏览文件 @
5adf98ae
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.20
2 2008/05/08 00:27:57
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.20
3 2008/05/08 17:04:26
momjian Exp $
PostgreSQL documentation
-->
...
...
@@ -1514,7 +1514,8 @@ lo_import 152801
<listitem>
<para>
Sets the output format to one of <literal>unaligned</literal>,
<literal>aligned</literal>, <literal>html</literal>,
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>,
<literal>latex</literal>, or <literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
...
...
@@ -1526,8 +1527,21 @@ lo_import 152801
is intended to create output that might be intended to be read
in by other programs (tab-separated, comma-separated).
<quote>Aligned</quote> mode is the standard, human-readable,
nicely formatted text output that is default. The
<quote><acronym>HTML</acronym></quote> and
nicely formatted text output that is default.
</para>
<para>
<quote>Wrapped</quote> is like <literal>aligned</> but wraps
output to the specified width. If <literal>\pset columns</> is
zero (the default), <literal>wrapped</> mode only affects screen
output and wrapped width is controlled by the environment
variable <envar>COLUMNS</> or the detected screen width. If
<literal>\pset columns</> is set to a non-zero value, all output
is wrapped, including file and pipe output.
</para>
<para>
The <quote><acronym>HTML</acronym></quote> and
<quote>LaTeX</quote> modes put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! (This might not be
...
...
@@ -1537,6 +1551,17 @@ lo_import 152801
</listitem>
</varlistentry>
<varlistentry>
<term><literal>columns</literal></term>
<listitem>
<para>
Controls the target width for the <literal>wrapped</> format.
Zero (the default) causes the <literal>wrapped</> format to
affect only screen output.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>border</literal></term>
<listitem>
...
...
@@ -2706,6 +2731,18 @@ $endif
<title>Environment</title>
<variablelist>
<varlistentry>
<term><envar>COLUMNS</envar></term>
<listitem>
<para>
Used for the <literal>wrapped</> output format if
<literal>\pset columns</> is zero.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>PAGER</envar></term>
...
...
src/bin/psql/command.c
浏览文件 @
5adf98ae
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.18
7 2008/05/02 09:27:50 petere
Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.18
8 2008/05/08 17:04:26 momjian
Exp $
*/
#include "postgres_fe.h"
#include "command.h"
...
...
@@ -1502,6 +1502,9 @@ _align2string(enum printFormat in)
case
PRINT_ALIGNED
:
return
"aligned"
;
break
;
case
PRINT_WRAPPED
:
return
"wrapped"
;
break
;
case
PRINT_HTML
:
return
"html"
;
break
;
...
...
@@ -1535,6 +1538,8 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt
->
topt
.
format
=
PRINT_UNALIGNED
;
else
if
(
pg_strncasecmp
(
"aligned"
,
value
,
vallen
)
==
0
)
popt
->
topt
.
format
=
PRINT_ALIGNED
;
else
if
(
pg_strncasecmp
(
"wrapped"
,
value
,
vallen
)
==
0
)
popt
->
topt
.
format
=
PRINT_WRAPPED
;
else
if
(
pg_strncasecmp
(
"html"
,
value
,
vallen
)
==
0
)
popt
->
topt
.
format
=
PRINT_HTML
;
else
if
(
pg_strncasecmp
(
"latex"
,
value
,
vallen
)
==
0
)
...
...
@@ -1543,7 +1548,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt
->
topt
.
format
=
PRINT_TROFF_MS
;
else
{
psql_error
(
"
\\
pset: allowed formats are unaligned, aligned, html, latex, troff-ms
\n
"
);
psql_error
(
"
\\
pset: allowed formats are unaligned, aligned,
wrapped,
html, latex, troff-ms
\n
"
);
return
false
;
}
...
...
@@ -1724,6 +1729,16 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
}
}
/* set border style/width */
else
if
(
strcmp
(
param
,
"columns"
)
==
0
)
{
if
(
value
)
popt
->
topt
.
columns
=
atoi
(
value
);
if
(
!
quiet
)
printf
(
_
(
"Target width for
\"
wrapped
\"
format is %d.
\n
"
),
popt
->
topt
.
columns
);
}
else
{
psql_error
(
"
\\
pset: unknown option: %s
\n
"
,
param
);
...
...
src/bin/psql/mbprint.c
浏览文件 @
5adf98ae
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.3
0 2008/04/16 18:18:00
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.3
1 2008/05/08 17:04:26
momjian Exp $
*
* XXX this file does not really belong in psql/. Perhaps move to libpq?
* It also seems that the mbvalidate function is redundant with existing
...
...
@@ -204,8 +204,8 @@ pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding)
/*
* pg_wcssize takes the given string in the given encoding and returns three
* values:
* result_width: Width in display character
of
longest line in string
* result_height: Number of lines in display output
* result_width: Width in display character
s of the
longest line in string
* result_height: Number of
new
lines in display output
* result_format_size: Number of bytes required to store formatted representation of string
*/
int
...
...
@@ -279,9 +279,14 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
return
width
;
}
/*
* Filter out unprintable characters, companion to wcs_size.
* Break input into lines based on \n. lineptr[i].ptr == NULL
* indicates the end of the array.
*/
void
pg_wcsformat
(
unsigned
char
*
pwcs
,
size_t
len
,
int
encoding
,
struct
lineptr
*
lines
,
int
count
)
struct
lineptr
*
lines
,
int
count
)
{
int
w
,
chlen
=
0
;
...
...
@@ -307,6 +312,7 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
if
(
count
==
0
)
exit
(
1
);
/* Screwup */
/* make next line point to remaining memory */
lines
->
ptr
=
ptr
;
}
else
if
(
*
pwcs
==
'\r'
)
/* Linefeed */
...
...
@@ -353,12 +359,13 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
}
len
-=
chlen
;
}
*
ptr
++
=
'\0'
;
lines
->
width
=
linewidth
;
lines
++
;
count
--
;
if
(
count
>
0
)
lines
->
ptr
=
NULL
;
*
ptr
++
=
'\0'
;
/* Terminate formatted string */
if
(
count
==
0
)
exit
(
1
);
/* Screwup */
(
lines
+
1
)
->
ptr
=
NULL
;
/* terminate line array */
}
unsigned
char
*
...
...
src/bin/psql/print.c
浏览文件 @
5adf98ae
此差异已折叠。
点击以展开。
src/bin/psql/print.h
浏览文件 @
5adf98ae
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.3
5 2008/01/01 19:45:5
6 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.3
6 2008/05/08 17:04:2
6 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
...
...
@@ -21,6 +21,7 @@ enum printFormat
PRINT_NOTHING
=
0
,
/* to make sure someone initializes this */
PRINT_UNALIGNED
,
PRINT_ALIGNED
,
PRINT_WRAPPED
,
PRINT_HTML
,
PRINT_LATEX
,
PRINT_TROFF_MS
...
...
@@ -47,6 +48,8 @@ typedef struct _printTableOpt
* decimal marker */
char
*
tableAttr
;
/* attributes for HTML <table ...> */
int
encoding
;
/* character encoding */
int
env_columns
;
/* $COLUMNS on psql start, 0 is unset */
int
columns
;
/* target width for wrapped format */
}
printTableOpt
;
...
...
src/bin/psql/startup.c
浏览文件 @
5adf98ae
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.14
6 2008/01/01 19:45:5
6 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.14
7 2008/05/08 17:04:2
6 momjian Exp $
*/
#include "postgres_fe.h"
...
...
@@ -147,6 +147,8 @@ main(int argc, char *argv[])
pset
.
popt
.
topt
.
start_table
=
true
;
pset
.
popt
.
topt
.
stop_table
=
true
;
pset
.
popt
.
default_footer
=
true
;
/* We must get COLUMNS here before readline() sets it */
pset
.
popt
.
topt
.
env_columns
=
getenv
(
"COLUMNS"
)
?
atoi
(
getenv
(
"COLUMNS"
))
:
0
;
pset
.
notty
=
(
!
isatty
(
fileno
(
stdin
))
||
!
isatty
(
fileno
(
stdout
)));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录