Simplify some code in getObjectTypeDescription()
This routine is designed to never return an empty description or NULL, providing description fallbacks even if missing objects are accepted, but it included a code path where this was considered possible. All the callers of this routine already consider NULL as not possible, so change a bit the code to map with the assumptions of the callers, and add more comments close to the callers of this routine to outline the behavior expected. This code is new as of 2a10fdc, so no backpatch is needed. Discussion: https://postgr.es/m/YMNY6RGPBRCeLmFb@paquier.xyz
This commit is contained in:
parent
bfd96b7a3d
commit
b56b83aa0d
@ -4278,7 +4278,7 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
tupdesc = BlessTupleDesc(tupdesc);
|
||||||
|
|
||||||
/* object type */
|
/* object type, which can never be NULL */
|
||||||
values[0] = CStringGetTextDatum(getObjectTypeDescription(&address, true));
|
values[0] = CStringGetTextDatum(getObjectTypeDescription(&address, true));
|
||||||
nulls[0] = false;
|
nulls[0] = false;
|
||||||
|
|
||||||
@ -4490,9 +4490,8 @@ getObjectTypeDescription(const ObjectAddress *object, bool missing_ok)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* an empty string is equivalent to no object found */
|
/* the result can never be empty */
|
||||||
if (buffer.len == 0)
|
Assert(buffer.len > 0);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return buffer.data;
|
return buffer.data;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user