Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
324385d6
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,发现更多精彩内容 >>
提交
324385d6
编写于
12月 11, 2009
作者:
A
Andrew Dunstan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add YAML to list of EXPLAIN formats. Greg Sabino Mullane, reviewed by Takahiro Itagaki.
上级
db738618
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
115 addition
and
12 deletion
+115
-12
contrib/auto_explain/auto_explain.c
contrib/auto_explain/auto_explain.c
+2
-1
doc/src/sgml/auto-explain.sgml
doc/src/sgml/auto-explain.sgml
+2
-2
doc/src/sgml/ref/explain.sgml
doc/src/sgml/ref/explain.sgml
+4
-4
doc/src/sgml/release-8.5.sgml
doc/src/sgml/release-8.5.sgml
+2
-2
src/backend/commands/explain.c
src/backend/commands/explain.c
+102
-1
src/include/commands/explain.h
src/include/commands/explain.h
+3
-2
未找到文件。
contrib/auto_explain/auto_explain.c
浏览文件 @
324385d6
...
...
@@ -6,7 +6,7 @@
* Copyright (c) 2008-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.
7 2009/08/10 05:46:49 tgl
Exp $
* $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.
8 2009/12/11 01:33:35 adunstan
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -29,6 +29,7 @@ static const struct config_enum_entry format_options[] = {
{
"text"
,
EXPLAIN_FORMAT_TEXT
,
false
},
{
"xml"
,
EXPLAIN_FORMAT_XML
,
false
},
{
"json"
,
EXPLAIN_FORMAT_JSON
,
false
},
{
"yaml"
,
EXPLAIN_FORMAT_YAML
,
false
},
{
NULL
,
0
,
false
}
};
...
...
doc/src/sgml/auto-explain.sgml
浏览文件 @
324385d6
<!-- $PostgreSQL: pgsql/doc/src/sgml/auto-explain.sgml,v 1.
4 2009/08/10 05:46:50 tgl
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/auto-explain.sgml,v 1.
5 2009/12/11 01:33:35 adunstan
Exp $ -->
<sect1 id="auto-explain">
<title>auto_explain</title>
...
...
@@ -114,7 +114,7 @@ LOAD 'auto_explain';
<varname>auto_explain.log_format</varname> selects the
<command>EXPLAIN</> output format to be used.
The allowed values are <literal>text</literal>, <literal>xml</literal>,
and <literal>json
</literal>. The default is text.
<literal>json</literal>, and <literal>yaml
</literal>. The default is text.
Only superusers can change this setting.
</para>
</listitem>
...
...
doc/src/sgml/ref/explain.sgml
浏览文件 @
324385d6
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/explain.sgml,v 1.4
6 2009/08/10 05:46:50 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/explain.sgml,v 1.4
7 2009/12/11 01:33:35 adunstan
Exp $
PostgreSQL documentation
-->
...
...
@@ -31,7 +31,7 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
EXPLAIN [ ( { ANALYZE <replaceable class="parameter">boolean</replaceable> | VERBOSE <replaceable class="parameter">boolean</replaceable> | COSTS <replaceable class="parameter">boolean</replaceable> | FORMAT { TEXT | XML | JSON } } [, ...] ) ] <replaceable class="parameter">statement</replaceable>
EXPLAIN [ ( { ANALYZE <replaceable class="parameter">boolean</replaceable> | VERBOSE <replaceable class="parameter">boolean</replaceable> | COSTS <replaceable class="parameter">boolean</replaceable> | FORMAT { TEXT | XML | JSON
| YAML
} } [, ...] ) ] <replaceable class="parameter">statement</replaceable>
EXPLAIN [ ANALYZE ] [ VERBOSE ] <replaceable class="parameter">statement</replaceable>
</synopsis>
</refsynopsisdiv>
...
...
@@ -143,8 +143,8 @@ ROLLBACK;
<term><literal>FORMAT</literal></term>
<listitem>
<para>
Specify the output format, which can be TEXT, XML,
or JSON
.
XML or JSON
output contains the same information as the text output
Specify the output format, which can be TEXT, XML,
JSON, or YAML
.
Non-text
output contains the same information as the text output
format, but is easier for programs to parse. This parameter defaults to
<literal>TEXT</literal>.
</para>
...
...
doc/src/sgml/release-8.5.sgml
浏览文件 @
324385d6
<!-- $PostgreSQL: pgsql/doc/src/sgml/release-8.5.sgml,v 1.
8 2009/11/26 21:20:12 tgl
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/release-8.5.sgml,v 1.
9 2009/12/11 01:33:35 adunstan
Exp $ -->
<sect1 id="release-8-5">
<title>Release 8.5alpha2</title>
...
...
@@ -176,7 +176,7 @@
</listitem>
<listitem>
<para>
EXPLAIN allows output of plans in XML
or JSON
format for automated
EXPLAIN allows output of plans in XML
, JSON, or YAML
format for automated
processing of explain plans by analysis or visualization tools.
</para>
</listitem>
...
...
src/backend/commands/explain.c
浏览文件 @
324385d6
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.19
3 2009/11/04 22:26:04 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.19
4 2009/12/11 01:33:35 adunstan
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -95,7 +95,9 @@ static void ExplainBeginOutput(ExplainState *es);
static
void
ExplainEndOutput
(
ExplainState
*
es
);
static
void
ExplainXMLTag
(
const
char
*
tagname
,
int
flags
,
ExplainState
*
es
);
static
void
ExplainJSONLineEnding
(
ExplainState
*
es
);
static
void
ExplainYAMLLineStarting
(
ExplainState
*
es
);
static
void
escape_json
(
StringInfo
buf
,
const
char
*
str
);
static
void
escape_yaml
(
StringInfo
buf
,
const
char
*
str
);
/*
...
...
@@ -135,6 +137,8 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString,
es
.
format
=
EXPLAIN_FORMAT_XML
;
else
if
(
strcmp
(
p
,
"json"
)
==
0
)
es
.
format
=
EXPLAIN_FORMAT_JSON
;
else
if
(
strcmp
(
p
,
"yaml"
)
==
0
)
es
.
format
=
EXPLAIN_FORMAT_YAML
;
else
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
...
...
@@ -1537,6 +1541,19 @@ ExplainPropertyList(const char *qlabel, List *data, ExplainState *es)
}
appendStringInfoChar
(
es
->
str
,
']'
);
break
;
case
EXPLAIN_FORMAT_YAML
:
ExplainYAMLLineStarting
(
es
);
escape_yaml
(
es
->
str
,
qlabel
);
appendStringInfoChar
(
es
->
str
,
':'
);
foreach
(
lc
,
data
)
{
appendStringInfoChar
(
es
->
str
,
'\n'
);
appendStringInfoSpaces
(
es
->
str
,
es
->
indent
*
2
+
2
);
appendStringInfoString
(
es
->
str
,
"- "
);
escape_yaml
(
es
->
str
,
(
const
char
*
)
lfirst
(
lc
));
}
break
;
}
}
...
...
@@ -1584,6 +1601,15 @@ ExplainProperty(const char *qlabel, const char *value, bool numeric,
else
escape_json
(
es
->
str
,
value
);
break
;
case
EXPLAIN_FORMAT_YAML
:
ExplainYAMLLineStarting
(
es
);
appendStringInfo
(
es
->
str
,
"%s: "
,
qlabel
);
if
(
numeric
)
appendStringInfoString
(
es
->
str
,
value
);
else
escape_yaml
(
es
->
str
,
value
);
break
;
}
}
...
...
@@ -1668,6 +1694,21 @@ ExplainOpenGroup(const char *objtype, const char *labelname,
es
->
grouping_stack
=
lcons_int
(
0
,
es
->
grouping_stack
);
es
->
indent
++
;
break
;
case
EXPLAIN_FORMAT_YAML
:
ExplainYAMLLineStarting
(
es
);
if
(
labelname
)
{
appendStringInfo
(
es
->
str
,
"%s:"
,
labelname
);
es
->
grouping_stack
=
lcons_int
(
1
,
es
->
grouping_stack
);
}
else
{
appendStringInfoChar
(
es
->
str
,
'-'
);
es
->
grouping_stack
=
lcons_int
(
0
,
es
->
grouping_stack
);
}
es
->
indent
++
;
break
;
}
}
...
...
@@ -1697,6 +1738,11 @@ ExplainCloseGroup(const char *objtype, const char *labelname,
appendStringInfoChar
(
es
->
str
,
labeled
?
'}'
:
']'
);
es
->
grouping_stack
=
list_delete_first
(
es
->
grouping_stack
);
break
;
case
EXPLAIN_FORMAT_YAML
:
es
->
indent
--
;
es
->
grouping_stack
=
list_delete_first
(
es
->
grouping_stack
);
break
;
}
}
...
...
@@ -1729,6 +1775,13 @@ ExplainDummyGroup(const char *objtype, const char *labelname, ExplainState *es)
}
escape_json
(
es
->
str
,
objtype
);
break
;
case
EXPLAIN_FORMAT_YAML
:
ExplainYAMLLineStarting
(
es
);
if
(
labelname
)
appendStringInfo
(
es
->
str
,
"%s:"
,
labelname
);
appendStringInfoString
(
es
->
str
,
objtype
);
break
;
}
}
...
...
@@ -1759,6 +1812,10 @@ ExplainBeginOutput(ExplainState *es)
es
->
grouping_stack
=
lcons_int
(
0
,
es
->
grouping_stack
);
es
->
indent
++
;
break
;
case
EXPLAIN_FORMAT_YAML
:
es
->
grouping_stack
=
lcons_int
(
0
,
es
->
grouping_stack
);
break
;
}
}
...
...
@@ -1784,6 +1841,10 @@ ExplainEndOutput(ExplainState *es)
appendStringInfoString
(
es
->
str
,
"
\n
]"
);
es
->
grouping_stack
=
list_delete_first
(
es
->
grouping_stack
);
break
;
case
EXPLAIN_FORMAT_YAML
:
es
->
grouping_stack
=
list_delete_first
(
es
->
grouping_stack
);
break
;
}
}
...
...
@@ -1796,6 +1857,7 @@ ExplainSeparatePlans(ExplainState *es)
switch
(
es
->
format
)
{
case
EXPLAIN_FORMAT_TEXT
:
case
EXPLAIN_FORMAT_YAML
:
/* add a blank line */
appendStringInfoChar
(
es
->
str
,
'\n'
);
break
;
...
...
@@ -1858,6 +1920,25 @@ ExplainJSONLineEnding(ExplainState *es)
appendStringInfoChar
(
es
->
str
,
'\n'
);
}
/*
* Indent a YAML line.
*/
static
void
ExplainYAMLLineStarting
(
ExplainState
*
es
)
{
Assert
(
es
->
format
==
EXPLAIN_FORMAT_YAML
);
if
(
linitial_int
(
es
->
grouping_stack
)
==
0
)
{
appendStringInfoChar
(
es
->
str
,
' '
);
linitial_int
(
es
->
grouping_stack
)
=
1
;
}
else
{
appendStringInfoChar
(
es
->
str
,
'\n'
);
appendStringInfoSpaces
(
es
->
str
,
es
->
indent
*
2
);
}
}
/*
* Produce a JSON string literal, properly escaping characters in the text.
*/
...
...
@@ -1902,3 +1983,23 @@ escape_json(StringInfo buf, const char *str)
}
appendStringInfoCharMacro
(
buf
,
'\"'
);
}
/*
* YAML is a superset of JSON: if we find quotable characters, we call escape_json
*/
static
void
escape_yaml
(
StringInfo
buf
,
const
char
*
str
)
{
const
char
*
p
;
for
(
p
=
str
;
*
p
;
p
++
)
{
if
((
unsigned
char
)
*
p
<
' '
||
strchr
(
"
\"\\\b\f\n\r\t
"
,
*
p
))
{
escape_json
(
buf
,
str
);
return
;
}
}
appendStringInfo
(
buf
,
"%s"
,
str
);
}
src/include/commands/explain.h
浏览文件 @
324385d6
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.4
1 2009/08/10 05:46:50 tgl
Exp $
* $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.4
2 2009/12/11 01:33:35 adunstan
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -19,7 +19,8 @@ typedef enum ExplainFormat
{
EXPLAIN_FORMAT_TEXT
,
EXPLAIN_FORMAT_XML
,
EXPLAIN_FORMAT_JSON
EXPLAIN_FORMAT_JSON
,
EXPLAIN_FORMAT_YAML
}
ExplainFormat
;
typedef
struct
ExplainState
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录