aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-06-12 16:29:11 +0900
committerMichael Paquier <michael@paquier.xyz>2021-06-12 16:29:11 +0900
commitb56b83aa0d6e044cf38d553f7a87f4b84708cac6 (patch)
treecbcf85eb81141d31335da6e6838dbdba23410e4a /src
parentbfd96b7a3dc26a8384d4185d274573fb6a46b033 (diff)
downloadpostgresql-b56b83aa0d6e044cf38d553f7a87f4b84708cac6.tar.gz
postgresql-b56b83aa0d6e044cf38d553f7a87f4b84708cac6.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/objectaddress.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index d79c3cde7c6..9882e549c4e 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -4278,7 +4278,7 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
tupdesc = BlessTupleDesc(tupdesc);
- /* object type */
+ /* object type, which can never be NULL */
values[0] = CStringGetTextDatum(getObjectTypeDescription(&address, true));
nulls[0] = false;
@@ -4490,9 +4490,8 @@ getObjectTypeDescription(const ObjectAddress *object, bool missing_ok)
*/
}
- /* an empty string is equivalent to no object found */
- if (buffer.len == 0)
- return NULL;
+ /* the result can never be empty */
+ Assert(buffer.len > 0);
return buffer.data;
}