Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
2ac4cf55
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,发现更多精彩内容 >>
提交
2ac4cf55
编写于
12月 09, 1997
作者:
T
Thomas G. Lockhart
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add information message about implicitly created indices.
Check for duplicate implicit index names and generate unique names.
上级
a440f8e3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
10 deletion
+78
-10
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+78
-10
未找到文件。
src/backend/parser/analyze.c
浏览文件 @
2ac4cf55
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.5
2 1997/12/04 23:07:18
thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.5
3 1997/12/09 01:44:14
thomas Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -366,6 +366,57 @@ makeTableName(void *elem,...)
return
(
name
);
}
/* makeTableName() */
char
*
CreateIndexName
(
char
*
tname
,
char
*
cname
,
char
*
label
,
List
*
indices
);
char
*
CreateIndexName
(
char
*
tname
,
char
*
cname
,
char
*
label
,
List
*
indices
)
{
int
pass
=
0
;
char
*
iname
=
NULL
;
List
*
ilist
;
IndexStmt
*
index
;
char
name2
[
NAMEDATALEN
+
1
];
/* use working storage, since we might be trying several possibilities */
strcpy
(
name2
,
cname
);
while
(
iname
==
NULL
)
{
iname
=
makeTableName
(
tname
,
name2
,
label
,
NULL
);
/* unable to make a name at all? then quit */
if
(
iname
==
NULL
)
break
;
#if PARSEDEBUG
printf
(
"CreateNameIndex- check %s against indices
\n
"
,
iname
);
#endif
ilist
=
indices
;
while
(
ilist
!=
NIL
)
{
index
=
lfirst
(
ilist
);
#if PARSEDEBUG
printf
(
"CreateNameIndex- compare %s with existing index %s
\n
"
,
iname
,
index
->
idxname
);
#endif
if
(
strcasecmp
(
iname
,
index
->
idxname
)
==
0
)
break
;
ilist
=
lnext
(
ilist
);
}
/* ran through entire list? then no name conflict found so done */
if
(
ilist
==
NIL
)
break
;
/* the last one conflicted, so try a new name component */
pfree
(
iname
);
iname
=
NULL
;
pass
++
;
sprintf
(
name2
,
"%s_%d"
,
cname
,
(
pass
+
1
));
}
return
(
iname
);
}
/* CreateIndexName() */
/*
* transformCreateStmt -
* transforms the "create table" statement
...
...
@@ -379,6 +430,7 @@ static Query *
transformCreateStmt
(
ParseState
*
pstate
,
CreateStmt
*
stmt
)
{
Query
*
q
;
int
have_pkey
=
FALSE
;
List
*
elements
;
Node
*
element
;
List
*
columns
;
...
...
@@ -541,9 +593,9 @@ printf("transformCreateStmt- found CHECK clause\n");
* For UNIQUE, create an index as for PRIMARY KEYS, but do not insist on NOT NULL.
*
* Note that this code does not currently look for all possible redundant cases
* and either ignore or stop with warning. The create
will
fail later when
* names for indices turn out to be redundant, or a user might
just fin
d
* extra useless indices which might
kill performance. - thomas 1997-12-04
* and either ignore or stop with warning. The create
might
fail later when
* names for indices turn out to be redundant, or a user might
have specifie
d
* extra useless indices which might
hurt performance. - thomas 1997-12-08
*/
ilist
=
NIL
;
while
(
dlist
!=
NIL
)
...
...
@@ -552,27 +604,38 @@ printf("transformCreateStmt- found CHECK clause\n");
if
(
nodeTag
(
constraint
)
!=
T_Constraint
)
elog
(
WARN
,
"parser: internal error; unrecognized deferred node"
,
NULL
);
if
((
constraint
->
contype
!=
CONSTR_PRIMARY
)
&&
(
constraint
->
contype
!=
CONSTR_UNIQUE
))
elog
(
WARN
,
"parser: internal error; illegal deferred constraint"
,
NULL
);
#if PARSEDEBUG
printf
(
"transformCreateStmt- found deferred constraint %s
\n
"
,
((
constraint
->
name
!=
NULL
)
?
constraint
->
name
:
"(unknown)"
));
#endif
if
(
constraint
->
contype
==
CONSTR_PRIMARY
)
if
(
have_pkey
)
elog
(
WARN
,
"CREATE TABLE/PRIMARY KEY multiple primary keys"
" for table %s are not legal"
,
stmt
->
relname
);
else
have_pkey
=
TRUE
;
else
if
(
constraint
->
contype
!=
CONSTR_UNIQUE
)
elog
(
WARN
,
"parser: internal error; unrecognized deferred constraint"
,
NULL
);
#if PARSEDEBUG
printf
(
"transformCreateStmt- found deferred %s clause
\n
"
,
(
constraint
->
contype
==
CONSTR_PRIMARY
?
"PRIMARY KEY"
:
"UNIQUE"
));
#endif
index
=
makeNode
(
IndexStmt
);
ilist
=
lappend
(
ilist
,
index
);
index
->
unique
=
TRUE
;
if
(
constraint
->
name
!=
NULL
)
index
->
idxname
=
constraint
->
name
;
else
if
(
constraint
->
contype
==
CONSTR_PRIMARY
)
{
if
(
have_pkey
)
elog
(
WARN
,
"CREATE TABLE/PRIMARY KEY multiple keys for table %s are not legal"
,
stmt
->
relname
);
have_pkey
=
TRUE
;
index
->
idxname
=
makeTableName
(
stmt
->
relname
,
"pkey"
,
NULL
);
}
else
index
->
idxname
=
NULL
;
...
...
@@ -619,7 +682,7 @@ printf("transformCreateStmt- mark column %s as NOT NULL\n", column->colname);
index
->
indexParams
=
lappend
(
index
->
indexParams
,
iparam
);
if
(
index
->
idxname
==
NULL
)
index
->
idxname
=
makeTableName
(
stmt
->
relname
,
iparam
->
name
,
"key"
,
NULL
);
index
->
idxname
=
CreateIndexName
(
stmt
->
relname
,
iparam
->
name
,
"key"
,
ilist
);
keys
=
lnext
(
keys
);
}
...
...
@@ -627,7 +690,12 @@ printf("transformCreateStmt- mark column %s as NOT NULL\n", column->colname);
if
(
index
->
idxname
==
NULL
)
elog
(
WARN
,
"parser: unable to construct implicit index for table %s"
"; name too long"
,
stmt
->
relname
);
else
elog
(
NOTICE
,
"CREATE TABLE/%s will create implicit index %s for table %s"
,
((
constraint
->
contype
==
CONSTR_PRIMARY
)
?
"PRIMARY KEY"
:
"UNIQUE"
),
index
->
idxname
,
stmt
->
relname
);
ilist
=
lappend
(
ilist
,
index
);
dlist
=
lnext
(
dlist
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录