!485 升级校验工具不校验 系统表的acl相关列

Merge pull request !485 from 胡正超/master
This commit is contained in:
opengauss_bot 2023-06-17 08:50:20 +00:00 committed by Gitee
commit fdd9f2900d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 49 additions and 20 deletions

View File

@ -21,12 +21,25 @@
import sys
import os
from upgrade_checker.utils.param import Param
from upgrade_checker.project import ProjectFactory
def program_workspace():
"""
If OM exists, use the log path of OM.
"""
gauss_log = os.getenv('GAUSSLOG')
om_log = os.path.join(gauss_log, 'om') if gauss_log is not None else None
if om_log is not None and os.access(om_log, os.F_OK):
return os.path.join(om_log, 'upgrade_checker')
return os.path.join(sys.path[0], 'upgrade_checker')
if __name__ == "__main__":
param = Param(sys.path[0] + '/upgrade_checker', sys.argv)
param = Param(program_workspace(), sys.argv)
if param.is_help():
print(param.helper)
exit(0)

View File

@ -31,7 +31,7 @@ config-params支持的参数选项及其默认值如下
-d | --debug
```
- port:数据库端口号
- port:数据库端口号
- debug:会打印更多的日志,用于工具问题定位。无参数,默认关闭,指定时开启。
- report-format:校验报告格式,当前仅支持markdown。
- report-mode:校验报告详细程度,支持`summary``detail`两种模式,默认`summary`模式。此选项仅会影响生成的报告的详细程度,并不影响校验内容的多少,`detail`仅是会把所有的校验规则无论对错都整理输出,报告整理比较耗时,而`summary`则仅整理输出错误的内容。
@ -89,7 +89,7 @@ upgrade-checker
|f- user-created-vmap -用户自己生成的校验地图
|f- report -某次检测的结果报告
|f-- README.md 说明书
|f-- main.py 入口脚本
|f-- gs_upgradechk 入口脚本
```
## 校验原理

View File

@ -74,6 +74,9 @@ class Project(object):
创建工作目录文件夹等
:return:
"""
if not os.access(self.dir_root, os.F_OK):
os.mkdir(self.dir_root, 0o700)
if not os.access(self.dir_workspace, os.F_OK):
os.mkdir(self.dir_workspace, 0o700)

View File

@ -92,7 +92,8 @@ META = {
[
ContentRulesMeta(
key='tmplname',
key_desc='名称为%s的模板'
key_desc='名称为%s的模板',
ignore_col='tmplacl'
)
]
),
@ -104,7 +105,8 @@ META = {
ContentRulesMeta(
key='spcname',
key_desc='名称为%s的表空间',
filters=' oid < 10000 '
filters=' oid < 10000 ',
ignore_col='spcacl'
)
]
),
@ -149,16 +151,17 @@ META = {
" attname"
")",
key_desc='模式.关系名(列名)为%s的列',
filters=' attrelid < 10000 '
filters=' attrelid < 10000 ',
ignore_col='attacl'
),
# initdb的。但忽略toast表,因为表名里也带oid,会变,无法校验。
ContentRulesMeta(
complete_sql="select format('%s.%s(%s)', n.nspname, c.relname, a.attname),"
" md5(format('%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s', "
" md5(format('%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s', "
" t.typname, a.attstattarget, a.attlen, a.attnum, a.attndims,"
" a.attcacheoff, a.atttypmod, a.attbyval, a.attstorage, a.attalign,"
" a.attnotnull, a.atthasdef,a.attisdropped, a.attislocal, a.attcmprmode,"
" a.attinhcount, a.attcollation, a.attacl, a.attoptions, a.attfdwoptions,"
" a.attinhcount, a.attcollation, a.attoptions, a.attfdwoptions,"
" a.attinitdefval, a.attkvtype))"
"from pg_attribute a left join pg_class c on a.attrelid = c.oid "
" left join pg_namespace n on c.relnamespace = n.oid "
@ -186,7 +189,7 @@ META = {
key="oid",
key_desc='oid为%s的函数或存储过程',
filters=' oid < 10000 ',
ignore_col='proargdefaults'
ignore_col='proargdefaults,proacl'
),
ContentRulesMeta(
key="format('%s.%s(%s)',"
@ -226,7 +229,7 @@ META = {
key="format('%s.%s',(select nspname from pg_namespace n where n.oid = relnamespace), relname)",
key_desc='名为%s的表或索引或视图等',
filters=' oid < 10000 ',
ignore_col='relfilenode,relpages,reltuples,relallvisible,relfrozenxid,relfrozenxid64,relminmxid',
ignore_col='relfilenode,relpages,reltuples,relallvisible,relacl,relfrozenxid,relfrozenxid64,relminmxid',
oid_col='oid,reltype,reloftype',
accuracy=Accuracy.STRICT
),
@ -239,7 +242,7 @@ META = {
oid_col='relnamespace,reltype,reloftype,relowner,reltablespace',
accuracy=Accuracy.STRICT
),
# 表的不需要使用pg_get_tabledef检查,会在第一步的校验系统表结构的时候校验。
# 表的会在第一步的校验系统表结构的时候校验pg_get_tabledef
# 索引等会在对应的扩展系统表校验,此处仅校验视图即可
ContentRulesMeta(
complete_sql="select format('def:%s.%s', n.nspname, c.relname), "
@ -297,13 +300,13 @@ META = {
key='datname',
key_desc='数据库%s',
filters=' oid < 10000 ',
ignore_col='encoding,datcollate,datctype,datlastsysoid,datfrozenxid,datfrozenxid64,datminmxid'
ignore_col='encoding,datcollate,datctype,datlastsysoid,datfrozenxid,datacl,datfrozenxid64,datminmxid'
),
ContentRulesMeta(
key='datname',
key_desc='数据库%s',
filters=' 9999 < oid and oid < 16384 ',
ignore_col='oid,encoding,datcollate,datctype,datlastsysoid,datfrozenxid,datfrozenxid64,datminmxid'
ignore_col='oid,encoding,datcollate,datctype,datlastsysoid,datfrozenxid,datacl,datfrozenxid64,datminmxid'
)
]
),
@ -315,7 +318,8 @@ META = {
ContentRulesMeta(
key='srvname',
key_desc='外表服务器%s',
filters=' oid < 10000 '
filters=' oid < 10000 ',
ignore_col='srvacl'
),
ContentRulesMeta(
complete_sql="select srvname, "
@ -622,13 +626,15 @@ META = {
ContentRulesMeta(
key='lanname',
key_desc='oid为%s的语言',
filters=' oid < 10000 '
filters=' oid < 10000 ',
ignore_col='lanacl'
),
ContentRulesMeta(
key='lanname',
key_desc='名称为%s的语言',
filters=' 9999 < oid and oid < 10000 ',
oid_col='oid,lanplcallfoid,laninline,lanvalidator',
ignore_col='lanacl',
oid_col='oid,lanplcallfoid,laninline,lanvalidator'
)
]
),
@ -653,13 +659,13 @@ META = {
key='nspname',
key_desc='名称为%s的schema',
filters=' oid < 10000 ',
ignore_col='nsptimeline,in_redistribution,nspblockchain,nspcollation'
ignore_col='nsptimeline,nspacl,in_redistribution,nspblockchain,nspcollation'
),
ContentRulesMeta(
key='nspname',
key_desc='名称为%s的schema',
filters=' 9999 < oid and oid < 16384 ',
ignore_col='nsptimeline,in_redistribution,nspblockchain,nspcollation',
ignore_col='nsptimeline,nspacl,in_redistribution,nspblockchain,nspcollation',
oid_col='oid,nspowner'
)
]
@ -820,6 +826,7 @@ META = {
key="lomowner",
key_desc='oid为%s的大对象元数据',
filters=' oid < 16384 ',
ignore_col='lomacl',
accuracy=Accuracy.ALLOW_MORE
)
]
@ -1203,6 +1210,7 @@ META = {
key="oid",
key_desc='oid为%s的外部数据源对象的信息',
filters=' oid < 16384 ',
ignore_col='srcacl',
accuracy=Accuracy.STRICT
)
]
@ -1216,6 +1224,7 @@ META = {
key="oid",
key_desc='oid为%s的文件夹',
filters=' oid < 16384 ',
ignore_col='srcacl',
accuracy=Accuracy.STRICT
)
]
@ -1325,6 +1334,7 @@ META = {
key="oid",
key_desc='oid为%s的package',
filters=' oid < 16384 ',
ignore_col='pkgacl',
accuracy=Accuracy.STRICT
)
]
@ -1383,6 +1393,7 @@ META = {
key="oid",
key_desc='oid为%s的节点组',
filters=' oid < 16384 ',
ignore_col='group_acl',
accuracy=Accuracy.STRICT
)
]
@ -1645,6 +1656,7 @@ META = {
key="oid",
key_desc='oid为%s的加密主密钥',
filters=' oid < 16384 ',
ignore_col='key_acl',
accuracy=Accuracy.STRICT
)
]
@ -1658,6 +1670,7 @@ META = {
key="oid",
key_desc='oid为%s的列加密密钥',
filters=' oid < 16384 ',
ignore_col='key_acl',
accuracy=Accuracy.STRICT
)
]

View File

@ -182,7 +182,7 @@ class Param(object):
return Action.HELP
action = argv[0]
if action in ("help", "--help", "-h", "-?"):
if action.lower() in ("help", "--help", "-h", "-?"):
return Action.HELP
elif action.lower() in ["check", "verify"]:
return Action.VERIFY
@ -210,7 +210,7 @@ class Param(object):
def assign_report_mode(gran):
if gran.lower() == 'summary':
return ReportMode.SUMMARY
elif gran.lower == 'detail':
elif gran.lower() == 'detail':
return ReportMode.DETAIL
else:
raise ParamParseException("错误的模式参数report-mode {0},仅支持summary、detail。".format(gran))