Re: doc: Clarify that empty COMMENT string removes the comment
shengbin Zhao <zshengbin91@gmail.com>
From: shengbin Zhao <zshengbin91@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-02-26T07:52:47Z
Lists: pgsql-hackers
On Thu, Feb 26, 2026 at 2:07 PM Chao Li <li.evan.chao@gmail.com> wrote: > Hi, > > 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. > > [1] > https://postgr.es/m/e08cb97f-0364-4002-9cda-3c16b42e4136@uni-muenster.de > [2] > https://postgr.es/m/CAHGQGwFJKg-aT5vajSU1v_B4K129u_SjZ3EGGHFSBhW967gcMA@mail.gmail.com > > Best regards, > -- > Chao Li (Evan) > HighGo Software Co., Ltd. > https://www.highgo.com/ > > > > > Hi Evan, I've looked at your patch, and I think your change is helpful. I applied it locally and rendered the html page, it looks good to me. Thanks! B.R, /Shengbin Zhao
Commits
-
doc: Clarify that empty COMMENT string removes the comment.
- 7ab6ac1d7f50 14.23 landed
- 4574dd44da3c 15.18 landed
- 228addbbf2c1 16.14 landed
- ec80fab7a1fd 17.10 landed
- 47ad672a76d3 18.4 landed
- bae42a54e3df 19 (unreleased) landed
-
Hello.
- 577e21b34f86 7.1.1 cited