diff options
-rw-r--r-- | src/backend/commands/analyze.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index f5dfb5f19f1..a930a67d626 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -845,12 +845,11 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr) stats->attrtypmod = attr->atttypmod; } - typtuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(stats->attrtypid)); + typtuple = SearchSysCacheCopy1(TYPEOID, + ObjectIdGetDatum(stats->attrtypid)); if (!HeapTupleIsValid(typtuple)) elog(ERROR, "cache lookup failed for type %u", stats->attrtypid); - stats->attrtype = (Form_pg_type) palloc(sizeof(FormData_pg_type)); - memcpy(stats->attrtype, GETSTRUCT(typtuple), sizeof(FormData_pg_type)); - ReleaseSysCache(typtuple); + stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple); stats->anl_context = anl_context; stats->tupattnum = attnum; @@ -879,7 +878,7 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr) if (!ok || stats->compute_stats == NULL || stats->minrows <= 0) { - pfree(stats->attrtype); + heap_freetuple(typtuple); pfree(stats->attr); pfree(stats); return NULL; |