Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
c63147d6
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,发现更多精彩内容 >>
提交
c63147d6
编写于
7月 03, 2008
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a function pg_get_keywords() to let clients find out the set of keywords
known to the SQL parser. Dave Page
上级
e3d9dcee
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
109 addition
and
9 deletion
+109
-9
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+20
-1
src/backend/parser/keywords.c
src/backend/parser/keywords.c
+5
-2
src/backend/utils/adt/misc.c
src/backend/utils/adt/misc.c
+72
-1
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+2
-2
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+4
-1
src/include/parser/keywords.h
src/include/parser/keywords.h
+4
-1
src/include/utils/builtins.h
src/include/utils/builtins.h
+2
-1
未找到文件。
doc/src/sgml/func.sgml
浏览文件 @
c63147d6
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.43
7 2008/05/19 18:08:15
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.43
8 2008/07/03 20:58:46
tgl Exp $ -->
<chapter
id=
"functions"
>
<title>
Functions and Operators
</title>
...
...
@@ -11484,6 +11484,10 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<primary>
format_type
</primary>
</indexterm>
<indexterm>
<primary>
pg_get_keywords
</primary>
</indexterm>
<indexterm>
<primary>
pg_get_viewdef
</primary>
</indexterm>
...
...
@@ -11538,6 +11542,11 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<entry><type>
text
</type></entry>
<entry>
get SQL name of a data type
</entry>
</row>
<row>
<entry><literal><function>
pg_get_keywords
</function>
()
</literal></entry>
<entry><type>
setof record
</type></entry>
<entry>
get list of SQL keywords and their categories
</entry>
</row>
<row>
<entry><literal><function>
pg_get_constraintdef
</function>
(
<parameter>
constraint_oid
</parameter>
)
</literal></entry>
<entry><type>
text
</type></entry>
...
...
@@ -11633,6 +11642,16 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
for the type modifier if no specific modifier is known.
</para>
<para>
<function>
pg_get_keywords
</function>
returns a set of records describing
the SQL keywords recognized by the server. The
<structfield>
word
</>
column
contains the keyword. The
<structfield>
catcode
</>
column contains a
category code:
<literal>
U
</>
for unreserved,
<literal>
C
</>
for column name,
<literal>
T
</>
for type or function name, or
<literal>
R
</>
for reserved.
The
<structfield>
catdesc
</>
column contains a possibly-localized string
describing the category.
</para>
<para>
<function>
pg_get_constraintdef
</function>
,
<function>
pg_get_indexdef
</function>
,
<function>
pg_get_ruledef
</function>
,
...
...
src/backend/parser/keywords.c
浏览文件 @
c63147d6
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.19
7 2008/05/21 19:51:01 meskes
Exp $
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.19
8 2008/07/03 20:58:46 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -41,7 +41,7 @@
* !!WARNING!!: This list must be sorted by ASCII name, because binary
* search is used to locate entries.
*/
static
const
ScanKeyword
ScanKeywords
[]
=
{
const
ScanKeyword
ScanKeywords
[]
=
{
/* name, value, category */
{
"abort"
,
ABORT_P
,
UNRESERVED_KEYWORD
},
{
"absolute"
,
ABSOLUTE_P
,
UNRESERVED_KEYWORD
},
...
...
@@ -428,6 +428,9 @@ static const ScanKeyword ScanKeywords[] = {
{
"zone"
,
ZONE
,
UNRESERVED_KEYWORD
},
};
/* End of ScanKeywords, for use elsewhere */
const
ScanKeyword
*
LastScanKeyword
=
endof
(
ScanKeywords
);
/*
* ScanKeywordLookup - see if a given word is a keyword
*
...
...
src/backend/utils/adt/misc.c
浏览文件 @
c63147d6
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.6
2 2008/04/17 20:56:41 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.6
3 2008/07/03 20:58:46 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,10 +20,12 @@
#include <math.h>
#include "access/xact.h"
#include "catalog/pg_type.h"
#include "catalog/pg_tablespace.h"
#include "commands/dbcommands.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "parser/keywords.h"
#include "postmaster/syslogger.h"
#include "storage/fd.h"
#include "storage/pmsignal.h"
...
...
@@ -322,3 +324,72 @@ pg_sleep(PG_FUNCTION_ARGS)
PG_RETURN_VOID
();
}
/* Function to return the list of grammar keywords */
Datum
pg_get_keywords
(
PG_FUNCTION_ARGS
)
{
FuncCallContext
*
funcctx
;
if
(
SRF_IS_FIRSTCALL
())
{
MemoryContext
oldcontext
;
TupleDesc
tupdesc
;
funcctx
=
SRF_FIRSTCALL_INIT
();
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
tupdesc
=
CreateTemplateTupleDesc
(
3
,
false
);
TupleDescInitEntry
(
tupdesc
,
(
AttrNumber
)
1
,
"word"
,
TEXTOID
,
-
1
,
0
);
TupleDescInitEntry
(
tupdesc
,
(
AttrNumber
)
2
,
"catcode"
,
CHAROID
,
-
1
,
0
);
TupleDescInitEntry
(
tupdesc
,
(
AttrNumber
)
3
,
"catdesc"
,
TEXTOID
,
-
1
,
0
);
funcctx
->
attinmeta
=
TupleDescGetAttInMetadata
(
tupdesc
);
MemoryContextSwitchTo
(
oldcontext
);
}
funcctx
=
SRF_PERCALL_SETUP
();
if
(
&
ScanKeywords
[
funcctx
->
call_cntr
]
<
LastScanKeyword
)
{
char
*
values
[
3
];
HeapTuple
tuple
;
/* cast-away-const is ugly but alternatives aren't much better */
values
[
0
]
=
(
char
*
)
ScanKeywords
[
funcctx
->
call_cntr
].
name
;
switch
(
ScanKeywords
[
funcctx
->
call_cntr
].
category
)
{
case
UNRESERVED_KEYWORD
:
values
[
1
]
=
"U"
;
values
[
2
]
=
_
(
"Unreserved"
);
break
;
case
COL_NAME_KEYWORD
:
values
[
1
]
=
"C"
;
values
[
2
]
=
_
(
"Column name"
);
break
;
case
TYPE_FUNC_NAME_KEYWORD
:
values
[
1
]
=
"T"
;
values
[
2
]
=
_
(
"Type or function name"
);
break
;
case
RESERVED_KEYWORD
:
values
[
1
]
=
"R"
;
values
[
2
]
=
_
(
"Reserved"
);
break
;
default:
/* shouldn't be possible */
values
[
1
]
=
NULL
;
values
[
2
]
=
NULL
;
break
;
}
tuple
=
BuildTupleFromCStrings
(
funcctx
->
attinmeta
,
values
);
SRF_RETURN_NEXT
(
funcctx
,
HeapTupleGetDatum
(
tuple
));
}
SRF_RETURN_DONE
(
funcctx
);
}
src/include/catalog/catversion.h
浏览文件 @
c63147d6
...
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.46
4 2008/06/24 17:58:27
tgl Exp $
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.46
5 2008/07/03 20:58:46
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 20080
624
1
#define CATALOG_VERSION_NO 20080
703
1
#endif
src/include/catalog/pg_proc.h
浏览文件 @
c63147d6
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.50
3 2008/06/17 19:10:5
6 tgl Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.50
4 2008/07/03 20:58:4
6 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
...
...
@@ -2288,6 +2288,9 @@ DESCR("deparse an encoded expression");
DATA
(
insert
OID
=
1665
(
pg_get_serial_sequence
PGNSP
PGUID
12
1
0
f
f
t
f
s
2
25
"25 25"
_null_
_null_
_null_
pg_get_serial_sequence
-
_null_
_null_
));
DESCR
(
"name of sequence for a serial column"
);
DATA
(
insert
OID
=
1686
(
pg_get_keywords
PGNSP
PGUID
12
10
400
f
f
t
t
s
0
2249
""
"{25,18,25}"
"{o,o,o}"
"{word,catcode,catdesc}"
pg_get_keywords
-
_null_
_null_
));
DESCR
(
"list of SQL keywords"
);
/* Generic referential integrity constraint triggers */
DATA
(
insert
OID
=
1644
(
RI_FKey_check_ins
PGNSP
PGUID
12
1
0
f
f
t
f
v
0
2279
""
_null_
_null_
_null_
RI_FKey_check_ins
-
_null_
_null_
));
...
...
src/include/parser/keywords.h
浏览文件 @
c63147d6
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/parser/keywords.h,v 1.2
4 2008/01/01 19:45:58 momjian
Exp $
* $PostgreSQL: pgsql/src/include/parser/keywords.h,v 1.2
5 2008/07/03 20:58:46 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -28,6 +28,9 @@ typedef struct ScanKeyword
int16
category
;
/* see codes above */
}
ScanKeyword
;
extern
const
ScanKeyword
ScanKeywords
[];
extern
const
ScanKeyword
*
LastScanKeyword
;
extern
const
ScanKeyword
*
ScanKeywordLookup
(
const
char
*
text
);
#endif
/* KEYWORDS_H */
src/include/utils/builtins.h
浏览文件 @
c63147d6
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.31
7 2008/06/17 19:10:56
tgl Exp $
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.31
8 2008/07/03 20:58:47
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -411,6 +411,7 @@ extern Datum pg_reload_conf(PG_FUNCTION_ARGS);
extern
Datum
pg_tablespace_databases
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_rotate_logfile
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_sleep
(
PG_FUNCTION_ARGS
);
extern
Datum
pg_get_keywords
(
PG_FUNCTION_ARGS
);
/* oid.c */
extern
Datum
oidin
(
PG_FUNCTION_ARGS
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录