Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
ab17fd19
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,发现更多精彩内容 >>
提交
ab17fd19
编写于
4月 03, 2001
作者:
P
Philip Warner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- Handle overridden attrs as per discussions 2-Apr-2001
- Dump CHECK constraints in OID order
上级
08bf4d79
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
126 addition
and
26 deletion
+126
-26
src/bin/pg_dump/common.c
src/bin/pg_dump/common.c
+107
-19
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_archiver.h
+2
-2
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+14
-4
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dump.h
+3
-1
未找到文件。
src/bin/pg_dump/common.c
浏览文件 @
ab17fd19
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.5
4 2001/03/22 04:00:11 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.5
5 2001/04/03 08:52:59 pjw
Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
...
...
@@ -21,6 +21,10 @@
* string to return - formatted type, or base type. If the base type
* is returned then fmtId is called on the string.
*
* Modifications 4-Apr-2001 - pjw@rhyme.com.au
* - Changed flagInhAttrs to check all parent tables for overridden settings
* and set flags accordingly.
*
* BEWARE: Since fmtId uses a static buffer, using 'useBaseTypeName' on more
* than one call in a line will cause problems.
*
...
...
@@ -39,7 +43,8 @@
static
char
**
findParentsByOid
(
TableInfo
*
tbinfo
,
int
numTables
,
InhInfo
*
inhinfo
,
int
numInherits
,
const
char
*
oid
,
int
*
numParents
);
int
*
numParents
,
int
(
**
parentIndices
)[]);
static
int
findTableByOid
(
TableInfo
*
tbinfo
,
int
numTables
,
const
char
*
oid
);
static
void
flagInhAttrs
(
TableInfo
*
tbinfo
,
int
numTables
,
InhInfo
*
inhinfo
,
int
numInherits
);
...
...
@@ -122,7 +127,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid)
/*
* findParentsByOid
* given the oid of a class, return the names of its parent classes
* and assign the number of parents
to the last argument
.
* and assign the number of parents
, and parent indices to the last arguments
.
*
*
* returns NULL if none
...
...
@@ -131,7 +136,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid)
static
char
**
findParentsByOid
(
TableInfo
*
tblinfo
,
int
numTables
,
InhInfo
*
inhinfo
,
int
numInherits
,
const
char
*
oid
,
int
*
numParentsPtr
)
int
*
numParentsPtr
,
int
(
**
parentIndices
)[]
)
{
int
i
,
j
;
...
...
@@ -152,6 +157,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
if
(
numParents
>
0
)
{
result
=
(
char
**
)
malloc
(
sizeof
(
char
*
)
*
numParents
);
(
*
parentIndices
)
=
malloc
(
sizeof
(
int
)
*
numParents
);
j
=
0
;
for
(
i
=
0
;
i
<
numInherits
;
i
++
)
{
...
...
@@ -169,13 +175,17 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
oid
);
exit
(
2
);
}
(
**
parentIndices
)[
j
]
=
parentInd
;
result
[
j
++
]
=
tblinfo
[
parentInd
].
relname
;
}
}
return
result
;
}
else
{
(
*
parentIndices
)
=
NULL
;
return
NULL
;
}
}
/*
...
...
@@ -415,6 +425,14 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
j
,
k
;
int
parentInd
;
int
inhAttrInd
;
int
(
*
parentIndices
)[];
bool
foundAttr
;
/* Attr was found in a parent */
bool
foundNotNull
;
/* Attr was NOT NULL in a parent */
bool
defaultsMatch
;
/* All non-empty defaults match */
bool
defaultsFound
;
/* Found a default in a parent */
char
*
attrDef
;
char
*
inhDef
;
/*
* we go backwards because the tables in tblinfo are in OID order,
...
...
@@ -423,27 +441,97 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
*/
for
(
i
=
numTables
-
1
;
i
>=
0
;
i
--
)
{
/* Sequences can never have parents, and attr info is undefined */
if
(
tblinfo
[
i
].
sequence
)
continue
;
/* Get all the parents and their indexes. */
tblinfo
[
i
].
parentRels
=
findParentsByOid
(
tblinfo
,
numTables
,
inhinfo
,
numInherits
,
tblinfo
[
i
].
oid
,
&
tblinfo
[
i
].
numParents
);
for
(
k
=
0
;
k
<
tblinfo
[
i
].
numParents
;
k
++
)
&
tblinfo
[
i
].
numParents
,
&
parentIndices
);
/*
* For each attr, check the parent info: if no parent has
* an attr with the same name, then it's not inherited. If there
* *is* an attr with the same name, then only dump it if:
*
* - it is NOT NULL and zero parents are NOT NULL
* OR
* - it has a default value AND the default value
* does not match all parent default values, or
* no parents specify a default.
*
* See discussion on -hackers around 2-Apr-2001.
*/
for
(
j
=
0
;
j
<
tblinfo
[
i
].
numatts
;
j
++
)
{
parentInd
=
findTableByName
(
tblinfo
,
numTables
,
tblinfo
[
i
].
parentRels
[
k
]);
if
(
parentInd
<
0
)
foundAttr
=
false
;
foundNotNull
=
false
;
defaultsMatch
=
true
;
defaultsFound
=
false
;
attrDef
=
tblinfo
[
i
].
adef_expr
[
j
];
for
(
k
=
0
;
k
<
tblinfo
[
i
].
numParents
;
k
++
)
{
/* shouldn't happen unless findParentsByOid is broken */
fprintf
(
stderr
,
"failed sanity check, table %s not found by flagInhAttrs
\n
"
,
tblinfo
[
i
].
parentRels
[
k
]);
exit
(
2
);
}
for
(
j
=
0
;
j
<
tblinfo
[
i
].
numatts
;
j
++
)
parentInd
=
(
*
parentIndices
)[
k
];
if
(
parentInd
<
0
)
{
/* shouldn't happen unless findParentsByOid is broken */
fprintf
(
stderr
,
"failed sanity check, table %s not found by flagInhAttrs
\n
"
,
tblinfo
[
i
].
parentRels
[
k
]);
exit
(
2
);
};
inhAttrInd
=
strInArray
(
tblinfo
[
i
].
attnames
[
j
],
tblinfo
[
parentInd
].
attnames
,
tblinfo
[
parentInd
].
numatts
);
if
(
inhAttrInd
!=
-
1
)
{
foundAttr
=
true
;
foundNotNull
|=
tblinfo
[
parentInd
].
notnull
[
inhAttrInd
];
if
(
attrDef
!=
NULL
)
/* It we have a default, check parent */
{
inhDef
=
tblinfo
[
parentInd
].
adef_expr
[
inhAttrInd
];
if
(
inhDef
!=
NULL
)
{
defaultsFound
=
true
;
defaultsMatch
&=
(
strcmp
(
attrDef
,
inhDef
)
==
0
);
};
};
};
};
/*
* Based on the scan of the parents, decide if we
* can rely on the inherited attr
*/
if
(
foundAttr
)
/* Attr was inherited */
{
if
(
strInArray
(
tblinfo
[
i
].
attnames
[
j
],
tblinfo
[
parentInd
].
attnames
,
tblinfo
[
parentInd
].
numatts
)
!=
-
1
)
tblinfo
[
i
].
inhAttrs
[
j
]
=
1
;
/* Set inherited flag by default */
tblinfo
[
i
].
inhAttrs
[
j
]
=
1
;
tblinfo
[
i
].
inhAttrDef
[
j
]
=
1
;
tblinfo
[
i
].
inhNotNull
[
j
]
=
1
;
/* Clear it if attr had a default, but parents did not, or mismatch */
if
(
(
attrDef
!=
NULL
)
&&
(
!
defaultsFound
||
!
defaultsMatch
)
)
{
tblinfo
[
i
].
inhAttrs
[
j
]
=
0
;
tblinfo
[
i
].
inhAttrDef
[
j
]
=
0
;
}
/* Clear it if NOT NULL and none of the parents were NOT NULL */
if
(
tblinfo
[
i
].
notnull
[
j
]
&&
!
foundNotNull
)
{
tblinfo
[
i
].
inhAttrs
[
j
]
=
0
;
tblinfo
[
i
].
inhNotNull
[
j
]
=
0
;
}
}
}
}
...
...
src/bin/pg_dump/pg_backup_archiver.h
浏览文件 @
ab17fd19
...
...
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.2
8 2001/04/01 05:42:51
pjw Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.2
9 2001/04/03 08:52:59
pjw Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* - Initial version.
...
...
@@ -68,7 +68,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 5
#define K_VERS_REV
0
#define K_VERS_REV
1
/* Data block types */
#define BLK_DATA 1
...
...
src/bin/pg_dump/pg_dump.c
浏览文件 @
ab17fd19
...
...
@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.19
8 2001/04/01 05:42:51
pjw Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.19
9 2001/04/03 08:52:59
pjw Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -1603,6 +1603,10 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
free
((
int
*
)
tblinfo
[
i
].
atttypmod
);
if
(
tblinfo
[
i
].
inhAttrs
)
free
((
int
*
)
tblinfo
[
i
].
inhAttrs
);
if
(
tblinfo
[
i
].
inhAttrDef
)
free
((
int
*
)
tblinfo
[
i
].
inhAttrDef
);
if
(
tblinfo
[
i
].
inhNotNull
)
free
((
int
*
)
tblinfo
[
i
].
inhNotNull
);
if
(
tblinfo
[
i
].
attnames
)
free
(
tblinfo
[
i
].
attnames
);
if
(
tblinfo
[
i
].
atttypedefns
)
...
...
@@ -2138,7 +2142,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
" where i.inhrelid = pg_relcheck.rcrelid "
" and c.rcname = pg_relcheck.rcname "
" and c.rcsrc = pg_relcheck.rcsrc "
" and c.rcrelid = i.inhparent) "
,
" and c.rcrelid = i.inhparent) "
" Order By oid "
,
tblinfo
[
i
].
oid
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
if
(
!
res2
||
...
...
@@ -2656,6 +2661,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tblinfo
[
i
].
typnames
=
(
char
**
)
malloc
(
ntups
*
sizeof
(
char
*
));
tblinfo
[
i
].
atttypmod
=
(
int
*
)
malloc
(
ntups
*
sizeof
(
int
));
tblinfo
[
i
].
inhAttrs
=
(
int
*
)
malloc
(
ntups
*
sizeof
(
int
));
tblinfo
[
i
].
inhAttrDef
=
(
int
*
)
malloc
(
ntups
*
sizeof
(
int
));
tblinfo
[
i
].
inhNotNull
=
(
int
*
)
malloc
(
ntups
*
sizeof
(
int
));
tblinfo
[
i
].
notnull
=
(
bool
*
)
malloc
(
ntups
*
sizeof
(
bool
));
tblinfo
[
i
].
adef_expr
=
(
char
**
)
malloc
(
ntups
*
sizeof
(
char
*
));
tblinfo
[
i
].
parentRels
=
NULL
;
...
...
@@ -2678,6 +2685,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tblinfo
[
i
].
atttypmod
[
j
]
=
atoi
(
PQgetvalue
(
res
,
j
,
i_atttypmod
));
tblinfo
[
i
].
inhAttrs
[
j
]
=
0
;
/* this flag is set in
* flagInhAttrs() */
tblinfo
[
i
].
inhAttrDef
[
j
]
=
0
;
tblinfo
[
i
].
inhNotNull
[
j
]
=
0
;
tblinfo
[
i
].
notnull
[
j
]
=
(
PQgetvalue
(
res
,
j
,
i_attnotnull
)[
0
]
==
't'
)
?
true
:
false
;
if
(
PQgetvalue
(
res
,
j
,
i_atthasdef
)[
0
]
==
't'
)
{
...
...
@@ -3829,12 +3839,12 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
tblinfo
[
i
].
atttypedefns
[
j
]);
/* Default value */
if
(
tblinfo
[
i
].
adef_expr
[
j
]
!=
NULL
)
if
(
tblinfo
[
i
].
adef_expr
[
j
]
!=
NULL
&&
tblinfo
[
i
].
inhAttrDef
[
j
]
==
0
)
appendPQExpBuffer
(
q
,
" DEFAULT %s"
,
tblinfo
[
i
].
adef_expr
[
j
]);
/* Not Null constraint */
if
(
tblinfo
[
i
].
notnull
[
j
])
if
(
tblinfo
[
i
].
notnull
[
j
]
&&
tblinfo
[
i
].
inhNotNull
[
j
]
==
0
)
appendPQExpBuffer
(
q
,
" NOT NULL"
);
actual_atts
++
;
...
...
src/bin/pg_dump/pg_dump.h
浏览文件 @
ab17fd19
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_dump.h,v 1.6
0 2001/03/23 04:49:56 momjian
Exp $
* $Id: pg_dump.h,v 1.6
1 2001/04/03 08:52:59 pjw
Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
...
...
@@ -93,6 +93,8 @@ typedef struct _tableInfo
int
*
inhAttrs
;
/* an array of flags, one for each
* attribute if the value is 1, then this
* attribute is an inherited attribute */
int
*
inhAttrDef
;
/* Flags indicating if attrdef is inherited */
int
*
inhNotNull
;
/* Flags indicating if NOT NULL in inherited */
char
**
attnames
;
/* the attribute names */
char
**
attoids
;
/* oids of the various attributes */
char
**
atttypedefns
;
/* formatted column type definitions */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录