Address review on attstattarget is nullable, define pg compatible functions for it

pull/7699/head
naisila 2024-10-16 21:52:51 +03:00
parent 7497419dc4
commit ef60a25b87
1 changed files with 11 additions and 5 deletions

View File

@ -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,
HeapTuple atttuple = SearchSysCache2(ATTNUM,
ObjectIdGetDatum(tableRelationId),
Int16GetDatum(attributeForm->attnum));
int32 targetAttstattarget = getAttstattarget_compat(tp);
ReleaseSysCache(tp);
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 };