Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
cff9c574
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,发现更多精彩内容 >>
提交
cff9c574
编写于
7月 14, 2005
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix malloc length for new numeric separator patch.
Centralize malloc into function.
上级
c3f1b0f4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
62 deletion
+26
-62
src/bin/psql/print.c
src/bin/psql/print.c
+26
-62
未找到文件。
src/bin/psql/print.c
浏览文件 @
cff9c574
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.6
3 2005/07/10 15:53:42
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.6
4 2005/07/14 06:46:17
momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
...
...
@@ -29,6 +29,20 @@
#include "mbprint.h"
static
void
*
pg_local_malloc
(
size_t
size
)
{
void
*
tmp
;
tmp
=
malloc
(
size
);
if
(
!
tmp
)
{
psql_error
(
"out of memory
\n
"
);
exit
(
EXIT_FAILURE
);
}
return
tmp
;
}
static
int
num_numericseps
(
const
char
*
my_str
)
{
...
...
@@ -46,6 +60,7 @@ num_numericseps(const char *my_str)
else
return
int_len
/
3
-
1
;
/* no leading separator */
}
static
int
len_with_numericsep
(
const
char
*
my_str
)
{
...
...
@@ -77,12 +92,7 @@ format_numericsep(char *my_str, char *numericsep)
if
(
digits_before_sep
==
0
)
new_len
--
;
/* no leading separator */
new_str
=
malloc
(
new_len
);
if
(
!
new_str
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
new_str
=
pg_local_malloc
(
new_len
+
1
);
for
(
i
=
0
,
j
=
0
;
;
i
++
,
j
++
)
{
...
...
@@ -167,13 +177,8 @@ print_unaligned_text(const char *title, const char *const *headers,
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
>
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
char
*
my_cell
=
malloc
(
len_with_numericsep
(
*
ptr
)
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
if
(
!
my_cell
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
fputs
(
my_cell
,
fout
);
...
...
@@ -249,13 +254,8 @@ print_unaligned_vertical(const char *title, const char *const *headers,
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
char
*
my_cell
=
malloc
(
len_with_numericsep
(
*
ptr
)
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
if
(
!
my_cell
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
fputs
(
my_cell
,
fout
);
...
...
@@ -482,13 +482,8 @@ print_aligned_text(const char *title, const char *const *headers,
{
if
(
strlen
(
*
ptr
)
>
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
char
*
my_cell
=
malloc
(
cell_w
[
i
]
);
char
*
my_cell
=
pg_local_malloc
(
cell_w
[
i
]
+
1
);
if
(
!
my_cell
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
fprintf
(
fout
,
"%*s%s"
,
widths
[
i
%
col_count
]
-
cell_w
[
i
],
""
,
my_cell
);
...
...
@@ -634,12 +629,7 @@ print_aligned_vertical(const char *title, const char *const *headers,
fprintf
(
fout
,
"%s
\n
"
,
title
);
/* make horizontal border */
divider
=
malloc
(
hwidth
+
dwidth
+
10
);
if
(
!
divider
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
divider
=
pg_local_malloc
(
hwidth
+
dwidth
+
10
);
divider
[
0
]
=
'\0'
;
if
(
opt_border
==
2
)
strcat
(
divider
,
"+-"
);
...
...
@@ -661,15 +651,9 @@ print_aligned_vertical(const char *title, const char *const *headers,
{
if
(
!
opt_barebones
)
{
char
*
record_str
=
malloc
(
32
);
char
*
record_str
=
pg_local_
malloc
(
32
);
size_t
record_str_len
;
if
(
!
record_str
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
if
(
opt_border
==
0
)
snprintf
(
record_str
,
32
,
"* Record %d"
,
record
++
);
else
...
...
@@ -709,13 +693,8 @@ print_aligned_vertical(const char *title, const char *const *headers,
fputs
(
" "
,
fout
);
{
char
*
my_cell
=
malloc
(
cell_w
[
i
]
);
char
*
my_cell
=
pg_local_malloc
(
cell_w
[
i
]
+
1
);
if
(
!
my_cell
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
strcpy
(
my_cell
,
*
ptr
);
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
...
...
@@ -855,13 +834,8 @@ print_html_text(const char *title, const char *const *headers,
else
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
char
*
my_cell
=
malloc
(
len_with_numericsep
(
*
ptr
)
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
if
(
!
my_cell
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
html_escaped_print
(
my_cell
,
fout
);
...
...
@@ -946,13 +920,8 @@ print_html_vertical(const char *title, const char *const *headers,
else
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
char
*
my_cell
=
malloc
(
len_with_numericsep
(
*
ptr
)
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
if
(
!
my_cell
)
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
html_escaped_print
(
my_cell
,
fout
);
...
...
@@ -1646,12 +1615,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
exit
(
EXIT_FAILURE
);
}
footers
[
0
]
=
malloc
(
100
);
if
(
!
footers
[
0
])
{
fprintf
(
stderr
,
_
(
"out of memory
\n
"
));
exit
(
EXIT_FAILURE
);
}
footers
[
0
]
=
pg_local_malloc
(
100
);
if
(
PQntuples
(
result
)
==
1
)
snprintf
(
footers
[
0
],
100
,
_
(
"(1 row)"
));
else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录