Fix incorrect comparison in pgxcnode_gethash master
authorTomas Vondra <[email protected]>
Fri, 12 Oct 2018 12:32:54 +0000 (14:32 +0200)
committerTomas Vondra <[email protected]>
Fri, 12 Oct 2018 12:35:34 +0000 (14:35 +0200)
The check is supposed to ensure NULL/empty nodename gets hashed to 0,
but (nodename == '\0') is comparing the pointer itself, not the first
character. So dereference that correctly.

src/gtm/recovery/register_common.c

index ff0f960e33adb3c3e36fdf0e8e63bbd992208eaa..e0afe1425fff91a150054ec2d4a2bd1f8c539b56 100644 (file)
@@ -174,7 +174,7 @@ pgxcnode_find_info(GTM_PGXCNodeType type, char *node_name)
 
 /*
  * Get the Hash Key depending on the node name
- * We do not except to have hundreds of nodes yet,
+ * We do not expect to have hundreds of nodes yet,
  * This function could be replaced by a better one
  * such as a double hash function indexed on type and Node Name
  */
@@ -186,7 +186,7 @@ pgxcnode_gethash(char *nodename)
        int                     value;
        uint32                  hash = 0;
 
-       if (nodename == NULL || nodename == '\0')
+       if (nodename == NULL || *nodename == '\0')
        {
                return 0;
        }