Skip to content

Commit b56b83a

Browse files
committed
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
1 parent bfd96b7 commit b56b83a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/backend/catalog/objectaddress.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4278,7 +4278,7 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
42784278

42794279
tupdesc = BlessTupleDesc(tupdesc);
42804280

4281-
/* object type */
4281+
/* object type, which can never be NULL */
42824282
values[0] = CStringGetTextDatum(getObjectTypeDescription(&address, true));
42834283
nulls[0] = false;
42844284

@@ -4490,9 +4490,8 @@ getObjectTypeDescription(const ObjectAddress *object, bool missing_ok)
44904490
*/
44914491
}
44924492

4493-
/* an empty string is equivalent to no object found */
4494-
if (buffer.len == 0)
4495-
return NULL;
4493+
/* the result can never be empty */
4494+
Assert(buffer.len > 0);
44964495

44974496
return buffer.data;
44984497
}

0 commit comments

Comments
 (0)