While reviewing patch [1] before the holiday vacation, I noticed that the COMMENT ON command treats an empty string as NULL, which effectively removes the comment from the object. Today I also saw discussion [2], which mentioned the same problem.
From the code, it seems the behavior is intentional: ``` /* Reduce empty-string to NULL case */ if (comment != NULL && strlen(comment) == 0) comment = NULL; ```
However, the documentation does not explain this behavior. It currently only says: ``` string_literal The new comment contents, written as a string literal. ```
Is it a common pattern that an empty string is treated as NULL, so that the documentation does not need to mention it explicitly? I don’t think so. For example, a similar command, SECURITY LABEL ON, treats an empty string as just an empty string.
This tiny patch enhances the documentation of COMMENT ON to clarify that an empty string is treated as NULL.