From ef60a25b87b9b654828e60307a86b578edd9a0c4 Mon Sep 17 00:00:00 2001 From: naisila Date: Wed, 16 Oct 2024 21:52:51 +0300 Subject: [PATCH] Address review on attstattarget is nullable, define pg compatible functions for it --- .../distributed/deparser/citus_ruleutils.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/backend/distributed/deparser/citus_ruleutils.c b/src/backend/distributed/deparser/citus_ruleutils.c index 6e61564b8..530f6e720 100644 --- a/src/backend/distributed/deparser/citus_ruleutils.c +++ b/src/backend/distributed/deparser/citus_ruleutils.c @@ -739,11 +739,17 @@ pg_get_tablecolumnoptionsdef_string(Oid tableRelationId) * If the user changed the column's statistics target, create * alter statement and add statement to a list for later processing. */ - HeapTuple tp = SearchSysCache2(ATTNUM, - ObjectIdGetDatum(tableRelationId), - Int16GetDatum(attributeForm->attnum)); - int32 targetAttstattarget = getAttstattarget_compat(tp); - ReleaseSysCache(tp); + HeapTuple atttuple = SearchSysCache2(ATTNUM, + ObjectIdGetDatum(tableRelationId), + Int16GetDatum(attributeForm->attnum)); + if (!HeapTupleIsValid(atttuple)) + { + elog(ERROR, "cache lookup failed for attribute %d of relation %u", + attributeForm->attnum, tableRelationId); + } + + int32 targetAttstattarget = getAttstattarget_compat(atttuple); + ReleaseSysCache(atttuple); if (targetAttstattarget >= 0) { StringInfoData statement = { NULL, 0, 0, 0 };