提交 3ab9ecb9 编写于 作者: C Chumki Roy

Separated missing issues from extra issues in gpcheckcat summary

In a previous commit, f569c1d1,
gpcheckcat was modified to display a list of tables with missing
attributes.  This commit adds the ability to list tables with
extraneous attributes.

Authors: Chumki Roy and James McAtamney
上级 57cc8456
......@@ -170,6 +170,7 @@ class Global():
self.checkStatus = True
self.failedChecks = []
self.missing_attr_tables = []
self.extra_attr_tables = []
GV = Global()
......@@ -4516,12 +4517,17 @@ class GPObject:
if 'relid' in key or key in ['ev_class', 'reloid', 'fmterrtbl']:
table_list = db.query(oid_query % issue.pkeys[key]).getresult()
if table_list:
GV.missing_attr_tables.append( (table_list[0][0], issue.segids) )
if issue.type == 'missing':
GV.missing_attr_tables.append( (table_list[0][0], issue.segids) )
else:
GV.extra_attr_tables.append( (table_list[0][0], issue.segids) )
elif key == 'oid':
table_list = db.query(type_query % issue.pkeys[key]).getresult()
if table_list:
GV.missing_attr_tables.append( (table_list[0][0], issue.segids) )
if issue.type == 'missing':
GV.missing_attr_tables.append( (table_list[0][0], issue.segids) )
else:
GV.extra_attr_tables.append( (table_list[0][0], issue.segids) )
def __cmp__(self, other):
......@@ -4747,7 +4753,7 @@ def checkcatReport():
myprint('')
# Report tables with missing attributes in a more usable format
if len(GV.missing_attr_tables):
if len(GV.missing_attr_tables) or len(GV.extra_attr_tables):
# Expand partition tables
db = connect2(GV.cfg[1], utilityMode=False)
parent_tables = [t[0] for t in db.query("SELECT DISTINCT (schemaname || '.' || tablename) FROM pg_partitions").getresult()]
......@@ -4766,17 +4772,32 @@ def checkcatReport():
""" % ("'" + "', '".join([pg.escape_string(t) for t in parent_tables]) + "'")
GV.missing_attr_tables = list(set(GV.missing_attr_tables))
myprint('----------------------------------------------------')
myprint(" Tables with missing issues:")
myprint(" Format [database name].[schema name].[table name].[segment id]:")
for table, segids in GV.missing_attr_tables:
if table in parent_tables:
for part_table in db.query(partition_leaves_sql).getresult():
GV.missing_attr_tables.append( (part_table[0], segids) )
for table, segids in sorted(GV.missing_attr_tables):
for id in segids[1:-1].split(','):
myprint(" Table %s.%s.%s" % (GV.dbname, table, id))
myprint('')
if len(GV.missing_attr_tables) > 0:
myprint('----------------------------------------------------')
myprint(" Tables with missing issues:")
myprint(" Format [database name].[schema name].[table name].[segment id]:")
for table, segids in GV.missing_attr_tables:
if table in parent_tables:
for part_table in db.query(partition_leaves_sql).getresult():
GV.missing_attr_tables.append( (part_table[0], segids) )
for table, segids in sorted(GV.missing_attr_tables):
for id in segids[1:-1].split(','):
myprint(" Table %s.%s.%s" % (GV.dbname, table, id))
myprint('')
GV.extra_attr_tables = list(set(GV.extra_attr_tables))
if len(GV.extra_attr_tables) > 0:
myprint('----------------------------------------------------')
myprint(" Tables with extra issues:")
myprint(" Format [database name].[schema name].[table name].[segment id]:")
for table, segids in GV.extra_attr_tables:
if table in parent_tables:
for part_table in db.query(partition_leaves_sql).getresult():
GV.extra_attr_tables.append( (part_table[0], segids) )
for table, segids in sorted(GV.extra_attr_tables):
for id in segids[1:-1].split(','):
myprint(" Table %s.%s.%s" % (GV.dbname, table, id))
myprint('')
myprint('')
notReported = set(GV.failedChecks).difference(reportedCheck)
......
......@@ -119,21 +119,23 @@ Feature: gpcheckcat tests
| fmterrtbl | pg_exttable |
| conrelid | pg_constraint |
Scenario: gpcheckcat should print out tables with missing attributes in a readable format
Scenario: gpcheckcat should print out tables with missing and extraneous attributes in a readable format
Given database "miss_attr" is dropped and recreated
And there is a "heap" table "public.heap_table" in "miss_attr" with data
And there is a "ao" table "public.ao_table" in "miss_attr" with data
When the user runs "gpcheckcat miss_attr"
And gpcheckcat should return a return code of 0
Then gpcheckcat should not print Missing to stdout
And the user runs "psql miss_attr -c "SET allow_system_table_mods='dml'; DELETE FROM pg_attribute where attrelid='heap_table'::regclass::oid;""
Then psql should return a return code of 0
And an attribute of table "ao_table" in database "miss_attr" is deleted on segment with content id "0"
And an attribute of table "heap_table" in database "miss_attr" is deleted on segment with content id "0"
And psql should return a return code of 0
When the user runs "gpcheckcat miss_attr"
Then gpcheckcat should print Missing to stdout
And gpcheckcat should print Table miss_attr.public.heap_table.-1 to stdout
And gpcheckcat should print Table miss_attr.public.ao_table.0 to stdout
And gpcheckcat should print Table miss_attr.public.heap_table.0 to stdout
And the user runs "psql miss_attr -c "SET allow_system_table_mods='dml'; DELETE FROM pg_attribute where attrelid='heap_table'::regclass::oid;""
Then psql should return a return code of 0
When the user runs "gpcheckcat miss_attr"
Then gpcheckcat should print Extra to stdout
And gpcheckcat should print Table miss_attr.public.heap_table.1 to stdout
Scenario: gpcheckcat should find owner error and produce timestamped repair scripts from -A (all databases) option
Given database "db1" is dropped and recreated
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册