diff --git a/gpMgmt/bin/gppylib/operations/dump.py b/gpMgmt/bin/gppylib/operations/dump.py index 2500104207cba98632c69ac9cc447f6bb4769b92..a84b3d4f2cbb1809d342c868c3deff7c92bdcf46 100755 --- a/gpMgmt/bin/gppylib/operations/dump.py +++ b/gpMgmt/bin/gppylib/operations/dump.py @@ -1634,13 +1634,18 @@ WHERE relname = '%s' AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspn outfile.write("""-- -- Schema: %s, Table: %s, Attribute: %s -- + +DELETE FROM pg_statistic WHERE starelid = %d AND staattnum = %d; + INSERT INTO pg_statistic VALUES ( %d::oid, %d::smallint, %f::real, %d::integer, %f::real, -""" % (nspname, relname, attname, starelid, staattnum, stanullfrac, stawidth, stadistinct)) +""" % (nspname, relname, attname, + starelid, staattnum, + starelid, staattnum, stanullfrac, stawidth, stadistinct)) # If a typname starts with exactly one it describes an array type # We can't restore statistics of array columns, so we'll zero and NULL everything out diff --git a/gpMgmt/bin/gppylib/operations/restore.py b/gpMgmt/bin/gppylib/operations/restore.py index d4da5f81c14666e33f9195d3af76816d6395cf3e..bce5a51ca1e276e6f9d2394dd2245296ed775d56 100755 --- a/gpMgmt/bin/gppylib/operations/restore.py +++ b/gpMgmt/bin/gppylib/operations/restore.py @@ -615,6 +615,9 @@ class RestoreDatabase(Operation): if replace_toggle and "::smallint" in line: line = " %s::smallint,\n" % new_attnum replace_toggle = False + if replace_toggle and "DELETE FROM" in line: + line = re.sub("starelid = (\w+)", "starelid = %s" % new_oid, line) + line = re.sub("staattnum = (\w+)", "staattnum = %s" % new_attnum, line) if print_toggle: outfile.write(line)