Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
ac0029aa
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,发现更多精彩内容 >>
提交
ac0029aa
编写于
8月 22, 1997
作者:
V
Vadim B. Mikheev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fetch information about DEFAULT/CHECK while openning a relation.
上级
9b6d8878
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
127 addition
and
30 deletion
+127
-30
src/backend/utils/cache/relcache.c
src/backend/utils/cache/relcache.c
+127
-30
未找到文件。
src/backend/utils/cache/relcache.c
浏览文件 @
ac0029aa
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.1
8 1997/08/21 04:09:51
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.1
9 1997/08/22 03:35:44
vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -82,6 +82,7 @@
#include "catalog/pg_log.h"
#include "catalog/pg_time.h"
#include "catalog/pg_attrdef.h"
#include "catalog/pg_relcheck.h"
#include "catalog/indexing.h"
#include "catalog/index.h"
#include "fmgr.h"
...
...
@@ -260,6 +261,7 @@ static void build_tupdesc_ind(RelationBuildDescInfo buildinfo,
static
Relation
RelationBuildDesc
(
RelationBuildDescInfo
buildinfo
);
static
void
IndexedAccessMethodInitialize
(
Relation
relation
);
static
void
AttrDefaultFetch
(
Relation
relation
);
static
void
RelCheckFetch
(
Relation
relation
);
/*
* newlyCreatedRelns -
...
...
@@ -482,7 +484,7 @@ AllocateRelationDesc(u_int natts, Form_pg_class relp)
* RelationBuildTupleDesc
*
* Form the relation's tuple descriptor from information in
* the pg_attribute
system catalog
.
* the pg_attribute
, pg_attrdef & pg_relcheck system cataloges
.
* --------------------------------
*/
static
void
...
...
@@ -499,13 +501,7 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
if
(
IsBootstrapProcessingMode
())
build_tupdesc_seq
(
buildinfo
,
relation
,
natts
);
else
{
relation
->
rd_att
->
constr
=
(
TupleConstr
*
)
palloc
(
sizeof
(
TupleConstr
));
relation
->
rd_att
->
constr
->
num_check
=
0
;
relation
->
rd_att
->
constr
->
num_defval
=
0
;
relation
->
rd_att
->
constr
->
has_not_null
=
false
;
build_tupdesc_ind
(
buildinfo
,
relation
,
natts
);
}
}
static
void
...
...
@@ -580,10 +576,13 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
Relation
attrel
;
HeapTuple
atttup
;
AttributeTupleForm
attp
;
TupleConstr
*
constr
=
(
TupleConstr
*
)
palloc
(
sizeof
(
TupleConstr
));
AttrDefault
*
attrdef
=
NULL
;
int
ndef
=
0
;
int
i
;
constr
->
has_not_null
=
false
;
attrel
=
heap_openr
(
AttributeRelationName
);
for
(
i
=
1
;
i
<=
relation
->
rd_rel
->
relnatts
;
i
++
)
{
...
...
@@ -604,7 +603,7 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
/* Update if this attribute have a constraint */
if
(
attp
->
attnotnull
)
relation
->
rd_att
->
constr
->
has_not_null
=
true
;
constr
->
has_not_null
=
true
;
if
(
attp
->
atthasdef
)
{
...
...
@@ -619,16 +618,39 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
}
heap_close
(
attrel
);
if
(
ndef
>
0
)
if
(
constr
->
has_not_null
||
ndef
>
0
||
relation
->
rd_rel
->
relchecks
)
{
if
(
ndef
>
relation
->
rd_rel
->
relnatts
)
relation
->
rd_att
->
constr
->
defval
=
(
AttrDefault
*
)
relation
->
rd_att
->
constr
=
constr
;
if
(
ndef
>
0
)
/* DEFAULTs */
{
if
(
ndef
<
relation
->
rd_rel
->
relnatts
)
constr
->
defval
=
(
AttrDefault
*
)
repalloc
(
attrdef
,
ndef
*
sizeof
(
AttrDefault
));
else
constr
->
defval
=
attrdef
;
constr
->
num_defval
=
ndef
;
AttrDefaultFetch
(
relation
);
}
else
relation
->
rd_att
->
constr
->
defval
=
attrdef
;
relation
->
rd_att
->
constr
->
num_defval
=
ndef
;
AttrDefaultFetch
(
relation
);
constr
->
num_defval
=
0
;
if
(
relation
->
rd_rel
->
relchecks
>
0
)
/* CHECKs */
{
constr
->
num_check
=
relation
->
rd_rel
->
relchecks
;
constr
->
check
=
(
ConstrCheck
*
)
palloc
(
constr
->
num_check
*
sizeof
(
ConstrCheck
));
memset
(
constr
->
check
,
0
,
constr
->
num_check
*
sizeof
(
ConstrCheck
));
RelCheckFetch
(
relation
);
}
else
constr
->
num_check
=
0
;
}
else
{
pfree
(
constr
);
relation
->
rd_att
->
constr
=
NULL
;
}
}
...
...
@@ -1252,8 +1274,6 @@ static void
RelationFlushRelation
(
Relation
*
relationPtr
,
bool
onlyFlushReferenceCountZero
)
{
int
i
;
AttributeTupleForm
*
p
;
MemoryContext
oldcxt
;
Relation
relation
=
*
relationPtr
;
...
...
@@ -1268,14 +1288,8 @@ RelationFlushRelation(Relation *relationPtr,
oldcxt
=
MemoryContextSwitchTo
((
MemoryContext
)
CacheCxt
);
RelationCacheDelete
(
relation
);
p
=
relation
->
rd_att
->
attrs
;
for
(
i
=
0
;
i
<
relation
->
rd_rel
->
relnatts
;
i
++
,
p
++
)
pfree
(
*
p
);
pfree
(
relation
->
rd_att
->
attrs
);
if
(
relation
->
rd_att
->
constr
)
pfree
(
relation
->
rd_att
->
constr
);
pfree
(
relation
->
rd_att
);
FreeTupleDesc
(
relation
->
rd_att
);
#if 0
if (relation->rd_rules) {
...
...
@@ -1641,8 +1655,9 @@ AttrDefaultFetch (Relation relation)
pfree
(
indexRes
);
if
(
!
HeapTupleIsValid
(
tuple
))
continue
;
found
++
;
adform
=
(
Form_pg_attrdef
)
GETSTRUCT
(
tuple
);
for
(
i
=
1
;
i
<=
ndef
;
i
++
)
for
(
i
=
0
;
i
<
ndef
;
i
++
)
{
if
(
adform
->
adnum
!=
attrdef
[
i
].
adnum
)
continue
;
...
...
@@ -1667,10 +1682,10 @@ AttrDefaultFetch (Relation relation)
NAMEDATALEN
,
relation
->
rd_att
->
attrs
[
adform
->
adnum
-
1
]
->
attname
.
data
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
attrdef
[
i
].
adsrc
=
textout
(
val
);
found
++
;
break
;
}
if
(
i
>
ndef
)
if
(
i
>
=
ndef
)
elog
(
WARN
,
"AttrDefaultFetch: unexpected record found for attr %d in rel %.*s"
,
adform
->
adnum
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
...
...
@@ -1689,6 +1704,88 @@ AttrDefaultFetch (Relation relation)
}
static
void
RelCheckFetch
(
Relation
relation
)
{
ConstrCheck
*
check
=
relation
->
rd_att
->
constr
->
check
;
int
ncheck
=
relation
->
rd_att
->
constr
->
num_check
;
Relation
rcrel
;
Relation
irel
;
ScanKeyData
skey
;
HeapTuple
tuple
;
IndexScanDesc
sd
;
RetrieveIndexResult
indexRes
;
Buffer
buffer
;
ItemPointer
iptr
;
Name
rcname
;
struct
varlena
*
val
;
bool
isnull
;
int
found
;
ScanKeyEntryInitialize
(
&
skey
,
(
bits16
)
0x0
,
(
AttrNumber
)
1
,
(
RegProcedure
)
ObjectIdEqualRegProcedure
,
ObjectIdGetDatum
(
relation
->
rd_id
));
rcrel
=
heap_openr
(
RelCheckRelationName
);
irel
=
index_openr
(
RelCheckIndex
);
sd
=
index_beginscan
(
irel
,
false
,
1
,
&
skey
);
tuple
=
(
HeapTuple
)
NULL
;
for
(
found
=
0
;
;
)
{
indexRes
=
index_getnext
(
sd
,
ForwardScanDirection
);
if
(
!
indexRes
)
break
;
iptr
=
&
indexRes
->
heap_iptr
;
tuple
=
heap_fetch
(
rcrel
,
NowTimeQual
,
iptr
,
&
buffer
);
pfree
(
indexRes
);
if
(
!
HeapTupleIsValid
(
tuple
))
continue
;
if
(
found
==
ncheck
)
elog
(
WARN
,
"RelCheckFetch: unexpected record found for rel %.*s"
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
rcname
=
(
Name
)
fastgetattr
(
tuple
,
Anum_pg_relcheck_rcname
,
rcrel
->
rd_att
,
&
isnull
);
if
(
isnull
)
elog
(
WARN
,
"RelCheckFetch: rcname IS NULL for rel %.*s"
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
check
[
found
].
ccname
=
nameout
(
rcname
);
val
=
(
struct
varlena
*
)
fastgetattr
(
tuple
,
Anum_pg_relcheck_rcbin
,
rcrel
->
rd_att
,
&
isnull
);
if
(
isnull
)
elog
(
WARN
,
"RelCheckFetch: rcbin IS NULL for rel %.*s"
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
check
[
found
].
ccbin
=
textout
(
val
);
val
=
(
struct
varlena
*
)
fastgetattr
(
tuple
,
Anum_pg_relcheck_rcsrc
,
rcrel
->
rd_att
,
&
isnull
);
if
(
isnull
)
elog
(
WARN
,
"RelCheckFetch: rcsrc IS NULL for rel %.*s"
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
check
[
found
].
ccsrc
=
textout
(
val
);
found
++
;
ReleaseBuffer
(
buffer
);
}
if
(
found
<
ncheck
)
elog
(
WARN
,
"RelCheckFetch: %d record not found for rel %.*s"
,
ncheck
-
found
,
NAMEDATALEN
,
relation
->
rd_rel
->
relname
.
data
);
index_endscan
(
sd
);
pfree
(
sd
);
index_close
(
irel
);
heap_close
(
rcrel
);
}
/*
* init_irels(), write_irels() -- handle special-case initialization of
* index relation descriptors.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录