From 5f226e04412eda4b7f12e64a24618772505c4c04 Mon Sep 17 00:00:00 2001 From: Junwang Zhao Date: Sat, 21 Dec 2024 12:13:40 +0000 Subject: [PATCH v1 2/3] reduce several trivial TODOs Signed-off-by: Junwang Zhao --- src/backend/catalog/objectaddress.c | 42 ++++++++++++++++++++++++----- src/backend/utils/cache/lsyscache.c | 19 +++++++++++++ src/include/utils/lsyscache.h | 1 + 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index d1bce431c7..6f967add87 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -6149,16 +6149,46 @@ getObjectIdentityParts(const ObjectAddress *object, } case PropgraphElementRelationId: - appendStringInfo(&buffer, "%u TODO", object->objectId); - break; + { + char *elemname; + + elemname = get_propgraph_element_alias_name(object->objectId); + if (elemname) + { + appendStringInfoString(&buffer, quote_identifier(elemname)); + if (objname) + *objname = list_make1(elemname); + } + break; + } case PropgraphLabelRelationId: - appendStringInfo(&buffer, "%u TODO", object->objectId); - break; + { + char *labelname; + + labelname = get_propgraph_label_name(object->objectId); + if (labelname) + { + appendStringInfoString(&buffer, quote_identifier(labelname)); + if (objname) + *objname = list_make1(labelname); + } + break; + } case PropgraphPropertyRelationId: - appendStringInfo(&buffer, "%u TODO", object->objectId); - break; + { + char *propname; + + propname = get_propgraph_property_name(object->objectId); + if (propname) + { + appendStringInfoString(&buffer, quote_identifier(propname)); + if (objname) + *objname = list_make1(propname); + } + break; + } case PublicationRelationId: { diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 3bf331b21a..6c081ca63f 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -32,6 +32,7 @@ #include "catalog/pg_opclass.h" #include "catalog/pg_operator.h" #include "catalog/pg_proc.h" +#include "catalog/pg_propgraph_element.h" #include "catalog/pg_propgraph_label.h" #include "catalog/pg_propgraph_property.h" #include "catalog/pg_publication.h" @@ -3717,6 +3718,24 @@ get_subscription_name(Oid subid, bool missing_ok) return subname; } +char * +get_propgraph_element_alias_name(Oid elemoid) +{ + HeapTuple tuple; + char *elemname; + + tuple = SearchSysCache1(PROPGRAPHELOID, elemoid); + if (!tuple) + { + elog(ERROR, "cache lookup failed for element %u", elemoid); + return NULL; + } + elemname = pstrdup(NameStr(((Form_pg_propgraph_element) GETSTRUCT(tuple))->pgealias)); + ReleaseSysCache(tuple); + + return elemname; +} + char * get_propgraph_label_name(Oid labeloid) { diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 82d0bbb267..7708793364 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -206,6 +206,7 @@ extern char *get_publication_name(Oid pubid, bool missing_ok); extern Oid get_subscription_oid(const char *subname, bool missing_ok); extern char *get_subscription_name(Oid subid, bool missing_ok); +extern char *get_propgraph_element_alias_name(Oid elemoid); extern char *get_propgraph_label_name(Oid labeloid); extern char *get_propgraph_property_name(Oid propoid); -- 2.39.5