Ensure pgxc_node_str returns the result in correct format
authorPavan Deolasee <[email protected]>
Wed, 29 Aug 2018 05:58:38 +0000 (11:28 +0530)
committerPavan Deolasee <[email protected]>
Wed, 29 Aug 2018 05:58:38 +0000 (11:28 +0530)
Per report from Krzysztof Nienartowicz, this broke the pgxc_clean command on
XL10.

src/backend/pgxc/pool/pgxcnode.c

index f6dfd2a48c6b546b3ab1f7a9e368b000782a9e2d..01d678dd2f0c6e67db224265e2de1fb883d8a468 100644 (file)
@@ -2566,7 +2566,15 @@ PGXCNodeGetNodeOid(int nodeid, char node_type)
 Datum
 pgxc_node_str(PG_FUNCTION_ARGS)
 {
-       PG_RETURN_TEXT_P(cstring_to_text(PGXCNodeName));
+       Name            result;
+       int                     len;
+
+       len = strlen(PGXCNodeName);
+       /* We use palloc0 here to ensure result is zero-padded */
+       result = (Name) palloc0(NAMEDATALEN);
+       memcpy(NameStr(*result), PGXCNodeName, NAMEDATALEN - 1);
+
+       PG_RETURN_NAME(result);
 }
 
 /*