Improve version detection for online help URL

Started by Japin Li20 days ago2 messageshackers
Jump to latest
#1Japin Li
japinli@hotmail.com

Hi hackers,

Currently, we are on 19beta1, and I found an invalid URL for an SQL command.

postgres=# \h SET SESSION
Command: SET SESSION AUTHORIZATION
Description: set the session user identifier and the current user identifier of the current session
Syntax:
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
RESET SESSION AUTHORIZATION

URL: https://www.postgresql.org/docs/19/sql-set-session-authorization.html

postgres=# SHOW server_version;
server_version
----------------
19beta1
(1 row)

The expected correct URL is:

https://www.postgresql.org/docs/devel/sql-set-session-authorization.html

In helpSQL(), the URL is currently formatted as:

url = psprintf("https://www.postgresql.org/docs/%s/%s.html",
strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,
QL_HELP[i].docbook_id);

According to the version_stamp.pl script, only released versions contain a dot
in PG_VERSION. Therefore, I think we should fix it as follows:

diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 5e0d8f3aae1..b80564debf0 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -714,7 +714,7 @@ helpSQL(const char *topic, unsigned short int pager)
 					initPQExpBuffer(&buffer);
 					QL_HELP[i].syntaxfunc(&buffer);
 					url = psprintf("https://www.postgresql.org/docs/%s/%s.html",
-								   strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,
+								   strstr(PG_VERSION, ".") ? PG_MAJORVERSION : "devel",
 								   QL_HELP[i].docbook_id);
 					/* # of newlines in format must match constant above! */
 					fprintf(output, _("Command:     %s\n"

Any thoughts?

--
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Japin Li (#1)
Re: Improve version detection for online help URL

On 04.06.26 05:19, Japin Li wrote:

Currently, we are on 19beta1, and I found an invalid URL for an SQL command.

postgres=# \h SET SESSION
Command: SET SESSION AUTHORIZATION
Description: set the session user identifier and the current user identifier of the current session
Syntax:
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION user_name
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
RESET SESSION AUTHORIZATION

URL: https://www.postgresql.org/docs/19/sql-set-session-authorization.html

This URL works now. It probably did not work before there was a
19-something release out.