psql show URL with help

Started by Peter Eisentrautalmost 7 years ago25 messages
#1Peter Eisentraut
peter.eisentraut@2ndquadrant.com

As mentioned on

https://www.cybertec-postgresql.com/en/looking-at-mysql-8-with-postgresql-goggles-on/

how about this:

=> \h analyze
Command: ANALYZE
Description: collect statistics about a database
Syntax:
ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]

where option can be one of:

VERBOSE
SKIP_LOCKED

and table_and_columns is:

table_name [ ( column_name [, ...] ) ]

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

(Won't actually work because the web site isn't serving "12" URLs yet,
but that's something that could probably be sorted out.)

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Peter Eisentraut (#1)
Re: psql show URL with help

čt 21. 2. 2019 v 18:28 odesílatel Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> napsal:

As mentioned on

https://www.cybertec-postgresql.com/en/looking-at-mysql-8-with-postgresql-goggles-on/

how about this:

=> \h analyze
Command: ANALYZE
Description: collect statistics about a database
Syntax:
ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]

where option can be one of:

VERBOSE
SKIP_LOCKED

and table_and_columns is:

table_name [ ( column_name [, ...] ) ]

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

(Won't actually work because the web site isn't serving "12" URLs yet,
but that's something that could probably be sorted out.)

Why not? It can be useful

Pavel

Show quoted text

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#3Julien Rouhaud
rjuju123@gmail.com
In reply to: Pavel Stehule (#2)
Re: psql show URL with help

On Thu, Feb 21, 2019 at 6:33 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:

čt 21. 2. 2019 v 18:28 odesílatel Peter Eisentraut <peter.eisentraut@2ndquadrant.com> napsal:

As mentioned on

https://www.cybertec-postgresql.com/en/looking-at-mysql-8-with-postgresql-goggles-on/

how about this:

=> \h analyze
Command: ANALYZE
Description: collect statistics about a database
Syntax:
ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]

where option can be one of:

VERBOSE
SKIP_LOCKED

and table_and_columns is:

table_name [ ( column_name [, ...] ) ]

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

(Won't actually work because the web site isn't serving "12" URLs yet,
but that's something that could probably be sorted out.)

Why not? It can be useful

Or just use the devel version for not-released-yet versions?

#4David Fetter
david@fetter.org
In reply to: Peter Eisentraut (#1)
Re: psql show URL with help

On Thu, Feb 21, 2019 at 06:28:09PM +0100, Peter Eisentraut wrote:

As mentioned on

https://www.cybertec-postgresql.com/en/looking-at-mysql-8-with-postgresql-goggles-on/

how about this:

=> \h analyze
Command: ANALYZE
Description: collect statistics about a database
Syntax:
ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]

where option can be one of:

VERBOSE
SKIP_LOCKED

and table_and_columns is:

table_name [ ( column_name [, ...] ) ]

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

(Won't actually work because the web site isn't serving "12" URLs yet,
but that's something that could probably be sorted out.)

Since there's no longer any mystery as to what the upcoming major
version of PostgreSQL will be, it should be pretty straightforward to
redirect integers > max(released version) to the devel docs.

This could cause some confusion because we branch long (feature- and
bug-wise) before we do the release, and a checkout from immediately
after branching will be *very* different from one just before the
release. The way I've come up with to clear this up is *way* too
expensive: lazily create doc builds for each SHA1 requested. Pointing
people at the latest devel docs is less confusing than pointing them
at nothing or at the previous version, those being, as far as I can
tell, the viable alternatives.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#5Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#1)
Re: psql show URL with help

On Thu, Feb 21, 2019 at 6:28 PM Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:

As mentioned on

https://www.cybertec-postgresql.com/en/looking-at-mysql-8-with-postgresql-goggles-on/

how about this:

=> \h analyze
Command: ANALYZE
Description: collect statistics about a database
Syntax:
ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]

where option can be one of:

VERBOSE
SKIP_LOCKED

and table_and_columns is:

table_name [ ( column_name [, ...] ) ]

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

I've had doing this on my TODO for a few years, but never managed to get
around to it. So strong +1 for the idea :)

(Won't actually work because the web site isn't serving "12" URLs yet,
but that's something that could probably be sorted out.)

Why not just link to /devel/ when it's a devel version? The 12 docs will be
up alongside the first beta version, so it should be perfectly possible to
have it do that based on information from configure, no?

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#6Euler Taveira
euler@timbira.com.br
In reply to: Peter Eisentraut (#1)
Re: psql show URL with help

Em qui, 21 de fev de 2019 às 14:28, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> escreveu:

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

What happen if I connect to an old server? Did it print URL according
to psql version or server version? psql prints help about its version
and if user wants details about a command, clicks in the URL but what
is shown is 12 docs but user is accessing a 9.4 server. Ops... the
command failed. Check the URL again but... wait it is not 9.4 docs.
There is also the case that some commands don't exist on old versions
but URL will be printed. IMHO URL should be printed iif psql version
is the same as server version. If we want flexibility, let's add an
option to enable URL exhibition (always/same) that defaults to same.

--
Euler Taveira Timbira -
http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

#7Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Euler Taveira (#6)
Re: psql show URL with help

On 2019-02-22 15:37, Euler Taveira wrote:

Em qui, 21 de fev de 2019 às 14:28, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> escreveu:

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

What happen if I connect to an old server? Did it print URL according
to psql version or server version? psql prints help about its version
and if user wants details about a command, clicks in the URL but what
is shown is 12 docs but user is accessing a 9.4 server. Ops... the
command failed. Check the URL again but... wait it is not 9.4 docs.

Well, the help that currently displays is also hardcoded to the psql
version. At least this way it would indicate in the URL that it might
pertain to a different version.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Euler Taveira (#6)
Re: psql show URL with help

Euler Taveira <euler@timbira.com.br> writes:

Em qui, 21 de fev de 2019 às 14:28, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> escreveu:

URL: https://www.postgresql.org/docs/12/sql-analyze.html

What happen if I connect to an old server? Did it print URL according
to psql version or server version? psql prints help about its version
and if user wants details about a command, clicks in the URL but what
is shown is 12 docs but user is accessing a 9.4 server.

The syntax summary that psql is showing is for its own version, and
I'd say the URL must be too. You can't even be sure that a corresponding
URL would exist in another version, so blindly inserting the server's
major version into a URL string that psql has doesn't seem like a bright
idea.

(I'm assuming that the implementation Peter has in mind is that these
URLs would just be part of the prefab help text that psql has for
various commands. If we somehow involved the server in it, then
maybe things could be different; but I doubt that's possible without
a protocol change, which it's probably not worth.)

In the end, if you are using a server version that's different from
your psql version, there are lots of ways things could go wrong.
I think it's up to the user to take psql's help with a grain of salt
in such cases.

regards, tom lane

#9Euler Taveira
euler@timbira.com.br
In reply to: Tom Lane (#8)
Re: psql show URL with help

Em sex, 22 de fev de 2019 às 11:55, Tom Lane <tgl@sss.pgh.pa.us> escreveu:

The syntax summary that psql is showing is for its own version, and
I'd say the URL must be too. You can't even be sure that a corresponding
URL would exist in another version, so blindly inserting the server's
major version into a URL string that psql has doesn't seem like a bright
idea.

I'm not suggesting that we replace version number using the latest
version URL. However, we could prevent URL to be shown if the version
mismatch. If psql wasn't backward compatible we shouldn't care but it
is. Someone could be confused as I said earlier.

--
Euler Taveira Timbira -
http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Euler Taveira (#9)
Re: psql show URL with help

Euler Taveira <euler@timbira.com.br> writes:

I'm not suggesting that we replace version number using the latest
version URL. However, we could prevent URL to be shown if the version
mismatch. If psql wasn't backward compatible we shouldn't care but it
is. Someone could be confused as I said earlier.

I tend to agree with Peter that showing the URL is actually better
than not doing so, in such a case --- it might remind the user
which version the help text is for.

regards, tom lane

#11Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Peter Eisentraut (#1)
1 attachment(s)
Re: psql show URL with help

On 2019-02-21 18:28, Peter Eisentraut wrote:

=> \h analyze

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

Here is a patch.

It doesn't deal with the "devel" paths yet. Discussion there is still
ongoing a bit.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

v1-0001-psql-Add-URL-to-help-output.patchtext/plain; charset=UTF-8; name=v1-0001-psql-Add-URL-to-help-output.patch; x-mac-creator=0; x-mac-type=0Download
From 962caa3b1a145c6f377f7e616515da5be864fcdc Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 25 Feb 2019 09:55:06 +0100
Subject: [PATCH v1] psql: Add URL to \help output

---
 src/bin/psql/create_help.pl | 10 ++++++++--
 src/bin/psql/help.c         |  7 +++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl
index 314bb5d87c..e8dd90d671 100644
--- a/src/bin/psql/create_help.pl
+++ b/src/bin/psql/create_help.pl
@@ -64,6 +64,7 @@
 {
 	const char	   *cmd;		/* the command name */
 	const char	   *help;		/* the help associated with it */
+	const char	   *docbook_id;	/* DocBook XML id (for generating URL) */
 	void (*syntaxfunc)(PQExpBuffer);	/* function that prints the syntax associated with it */
 	int				nl_count;	/* number of newlines in syntax (for pager) */
 };
@@ -92,7 +93,7 @@
 
 foreach my $file (sort readdir DIR)
 {
-	my (@cmdnames, $cmddesc, $cmdsynopsis);
+	my ($cmdid, @cmdnames, $cmddesc, $cmdsynopsis);
 	$file =~ /\.sgml$/ or next;
 
 	open(my $fh, '<', "$docdir/$file") or next;
@@ -104,6 +105,9 @@
 	  m!<refmiscinfo>\s*SQL - Language Statements\s*</refmiscinfo>!i
 	  or next;
 
+	$filecontent =~ m!<refentry id="([a-z-]+)">!
+	  and $cmdid = $1;
+
 	# Collect multiple refnames
   LOOP:
 	{
@@ -116,7 +120,7 @@
 	$filecontent =~ m!<synopsis>\s*(.+?)\s*</synopsis>!is
 	  and $cmdsynopsis = $1;
 
-	if (@cmdnames && $cmddesc && $cmdsynopsis)
+	if (@cmdnames && $cmddesc && $cmdid && $cmdsynopsis)
 	{
 		s/\"/\\"/g foreach @cmdnames;
 
@@ -146,6 +150,7 @@
 		foreach my $cmdname (@cmdnames)
 		{
 			$entries{$cmdname} = {
+				cmdid       => $cmdid,
 				cmddesc     => $cmddesc,
 				cmdsynopsis => $cmdsynopsis,
 				params      => \@params,
@@ -188,6 +193,7 @@
 	$id =~ s/ /_/g;
 	print $cfile_handle "    { \"$_\",
       N_(\"$entries{$_}{cmddesc}\"),
+      \"$entries{$_}{cmdid}\",
       sql_help_$id,
       $entries{$_}{nl_count} },
 
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 7c6fa2c590..4fbc4dde91 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -627,10 +627,13 @@ helpSQL(const char *topic, unsigned short int pager)
 					help_found = true;
 					fprintf(output, _("Command:     %s\n"
 									  "Description: %s\n"
-									  "Syntax:\n%s\n\n"),
+									  "Syntax:\n%s\n\n"
+									  "URL: https://www.postgresql.org/docs/%s/%s.html\n\n"),
 							QL_HELP[i].cmd,
 							_(QL_HELP[i].help),
-							buffer.data);
+							buffer.data,
+							PG_MAJORVERSION,
+							QL_HELP[i].docbook_id);
 					/* If we have an exact match, exit.  Fixes \h SELECT */
 					if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
 						break;
-- 
2.20.1

#12Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Magnus Hagander (#5)
Re: psql show URL with help

On 2019-02-22 12:07, Magnus Hagander wrote:

(Won't actually work because the web site isn't serving "12" URLs yet,
but that's something that could probably be sorted out.)

Why not just link to /devel/ when it's a devel version? The 12 docs will
be up alongside the first beta version, so it should be perfectly
possible to have it do that based on information from configure, no?

Why not just serve /12/ from the web site earlier? Is there a reason
not to?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#13Pavel Stehule
pavel.stehule@gmail.com
In reply to: Peter Eisentraut (#12)
Re: psql show URL with help

po 25. 2. 2019 v 12:06 odesílatel Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> napsal:

On 2019-02-22 12:07, Magnus Hagander wrote:

(Won't actually work because the web site isn't serving "12" URLs

yet,

but that's something that could probably be sorted out.)

Why not just link to /devel/ when it's a devel version? The 12 docs will
be up alongside the first beta version, so it should be perfectly
possible to have it do that based on information from configure, no?

Why not just serve /12/ from the web site earlier? Is there a reason
not to?

I had same idea. The fact so this version is development version, can be
solved by some styles.

But a URL should be stable.

Regards

Pavel

Show quoted text

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#14Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Peter Eisentraut (#11)
1 attachment(s)
Re: psql show URL with help

On 2019-02-25 12:05, Peter Eisentraut wrote:

On 2019-02-21 18:28, Peter Eisentraut wrote:

=> \h analyze

URL: https://www.postgresql.org/docs/12/sql-analyze.html
^^^^

Here is a patch.

It doesn't deal with the "devel" paths yet. Discussion there is still
ongoing a bit.

A new patch that now handles the "devel" part. Seems easy enough.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

v2-0001-psql-Add-documentation-URL-to-help-output.patchtext/plain; charset=UTF-8; name=v2-0001-psql-Add-documentation-URL-to-help-output.patch; x-mac-creator=0; x-mac-type=0Download
From 8268421dd39f413e21ce3e935eee1d0b5e607db2 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 27 Feb 2019 09:09:21 +0100
Subject: [PATCH v2] psql: Add documentation URL to \help output

---
 src/bin/psql/create_help.pl | 10 ++++++++--
 src/bin/psql/help.c         | 11 +++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl
index 314bb5d87c..e8dd90d671 100644
--- a/src/bin/psql/create_help.pl
+++ b/src/bin/psql/create_help.pl
@@ -64,6 +64,7 @@
 {
 	const char	   *cmd;		/* the command name */
 	const char	   *help;		/* the help associated with it */
+	const char	   *docbook_id;	/* DocBook XML id (for generating URL) */
 	void (*syntaxfunc)(PQExpBuffer);	/* function that prints the syntax associated with it */
 	int				nl_count;	/* number of newlines in syntax (for pager) */
 };
@@ -92,7 +93,7 @@
 
 foreach my $file (sort readdir DIR)
 {
-	my (@cmdnames, $cmddesc, $cmdsynopsis);
+	my ($cmdid, @cmdnames, $cmddesc, $cmdsynopsis);
 	$file =~ /\.sgml$/ or next;
 
 	open(my $fh, '<', "$docdir/$file") or next;
@@ -104,6 +105,9 @@
 	  m!<refmiscinfo>\s*SQL - Language Statements\s*</refmiscinfo>!i
 	  or next;
 
+	$filecontent =~ m!<refentry id="([a-z-]+)">!
+	  and $cmdid = $1;
+
 	# Collect multiple refnames
   LOOP:
 	{
@@ -116,7 +120,7 @@
 	$filecontent =~ m!<synopsis>\s*(.+?)\s*</synopsis>!is
 	  and $cmdsynopsis = $1;
 
-	if (@cmdnames && $cmddesc && $cmdsynopsis)
+	if (@cmdnames && $cmddesc && $cmdid && $cmdsynopsis)
 	{
 		s/\"/\\"/g foreach @cmdnames;
 
@@ -146,6 +150,7 @@
 		foreach my $cmdname (@cmdnames)
 		{
 			$entries{$cmdname} = {
+				cmdid       => $cmdid,
 				cmddesc     => $cmddesc,
 				cmdsynopsis => $cmdsynopsis,
 				params      => \@params,
@@ -188,6 +193,7 @@
 	$id =~ s/ /_/g;
 	print $cfile_handle "    { \"$_\",
       N_(\"$entries{$_}{cmddesc}\"),
+      \"$entries{$_}{cmdid}\",
       sql_help_$id,
       $entries{$_}{nl_count} },
 
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 7c6fa2c590..6b781afc6c 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -621,16 +621,23 @@ helpSQL(const char *topic, unsigned short int pager)
 					strcmp(topic, "*") == 0)
 				{
 					PQExpBufferData buffer;
+					char	   *url;
 
 					initPQExpBuffer(&buffer);
 					QL_HELP[i].syntaxfunc(&buffer);
 					help_found = true;
+					url = psprintf("https://www.postgresql.org/docs/%s/%s.html",
+								   strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,
+								   QL_HELP[i].docbook_id);
 					fprintf(output, _("Command:     %s\n"
 									  "Description: %s\n"
-									  "Syntax:\n%s\n\n"),
+									  "Syntax:\n%s\n\n"
+									  "URL: %s\n\n"),
 							QL_HELP[i].cmd,
 							_(QL_HELP[i].help),
-							buffer.data);
+							buffer.data,
+							url);
+					free(url);
 					/* If we have an exact match, exit.  Fixes \h SELECT */
 					if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
 						break;

base-commit: bc09d5e4cc1813c9af60c4537fe7d70ed1baae11
-- 
2.20.1

#15David Fetter
david@fetter.org
In reply to: Peter Eisentraut (#14)
Re: psql show URL with help

On Wed, Feb 27, 2019 at 09:14:59AM +0100, Peter Eisentraut wrote:

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

Do we need to make sure that the docs are published under the major
version as soon as we get to alpha, or do we need something more like
this?

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

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#16Ramanarayana
raam.soft@gmail.com
In reply to: David Fetter (#15)
Re: psql show URL with help

Hi,
Is there any documentation change required for this patch?
Cheers
Ram 4.0

#17Magnus Hagander
magnus@hagander.net
In reply to: David Fetter (#15)
Re: psql show URL with help

On Sun, Mar 3, 2019 at 7:14 PM David Fetter <david@fetter.org> wrote:

On Wed, Feb 27, 2019 at 09:14:59AM +0100, Peter Eisentraut wrote:

+ url = psprintf("

https://www.postgresql.org/docs/%s/%s.html&quot;,

+

strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,

+

QL_HELP[i].docbook_id);

Do we need to make sure that the docs are published under the major
version as soon as we get to alpha, or do we need something more like
this?

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

We don't really release alphas any more. And we do load the documentation
alongside the betas. (Last time we did an alpha was so long ago I don't
remember if we loaded docs)

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#18David Fetter
david@fetter.org
In reply to: Magnus Hagander (#17)
Re: psql show URL with help

On Sun, Mar 03, 2019 at 09:57:25PM +0100, Magnus Hagander wrote:

On Sun, Mar 3, 2019 at 7:14 PM David Fetter <david@fetter.org> wrote:

On Wed, Feb 27, 2019 at 09:14:59AM +0100, Peter Eisentraut wrote:

+ url = psprintf("

https://www.postgresql.org/docs/%s/%s.html&quot;,

+

strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,

+

QL_HELP[i].docbook_id);

Do we need to make sure that the docs are published under the major
version as soon as we get to alpha, or do we need something more like
this?

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

We don't really release alphas any more. And we do load the documentation
alongside the betas. (Last time we did an alpha was so long ago I don't
remember if we loaded docs)

If the first thing we do when we move from devel to some other state
(beta, RC, etc.) is to publish the docs under the major version
number, then maybe this test should be more along the lines of looking
for anything that's neither devel nor a number, extract the number,
and use that.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#19Magnus Hagander
magnus@hagander.net
In reply to: David Fetter (#18)
Re: psql show URL with help

On Sun, Mar 3, 2019 at 10:48 PM David Fetter <david@fetter.org> wrote:

On Sun, Mar 03, 2019 at 09:57:25PM +0100, Magnus Hagander wrote:

On Sun, Mar 3, 2019 at 7:14 PM David Fetter <david@fetter.org> wrote:

On Wed, Feb 27, 2019 at 09:14:59AM +0100, Peter Eisentraut wrote:

+ url = psprintf("

https://www.postgresql.org/docs/%s/%s.html&quot;,

+

strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,

+

QL_HELP[i].docbook_id);

Do we need to make sure that the docs are published under the major
version as soon as we get to alpha, or do we need something more like
this?

url = psprintf("https://www.postgresql.org/docs/%s/%s.html&quot;,
(strstr(PG_VERSION, "devel") || strstr(PG_VERSION, "beta")

||

strstr(PG_VERSION, "alpha")) : "devel" : PG_MAJORVERSION,
QL_HELP[i].docbook_id);

We don't really release alphas any more. And we do load the documentation
alongside the betas. (Last time we did an alpha was so long ago I don't
remember if we loaded docs)

If the first thing we do when we move from devel to some other state
(beta, RC, etc.) is to publish the docs under the major version
number, then maybe this test should be more along the lines of looking
for anything that's neither devel nor a number, extract the number,
and use that.

Well, alpha versions do go under the numeric URL. Whether we load the docs
at that time or not we can just choose -- but there is no reason not to. So
yeah, that sounds like it would work better.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#20Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Magnus Hagander (#19)
Re: psql show URL with help

On 2019-03-04 17:55, Magnus Hagander wrote:

If the first thing we do when we move from devel to some other state
(beta, RC, etc.) is to publish the docs under the major version
number, then maybe this test should be more along the lines of looking
for anything that's neither devel nor a number, extract the number,
and use that.

Well, alpha versions do go under the numeric URL. Whether we load the
docs at that time or not we can just choose -- but there is no reason
not to. So yeah, that sounds like it would work better. 

Can you put your proposal in the form of some logical pseudocode? I
don't understand the free-form description.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#21Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#20)
Re: psql show URL with help

On Mon, Mar 4, 2019 at 11:41 PM Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:

On 2019-03-04 17:55, Magnus Hagander wrote:

If the first thing we do when we move from devel to some other state
(beta, RC, etc.) is to publish the docs under the major version
number, then maybe this test should be more along the lines of

looking

for anything that's neither devel nor a number, extract the number,
and use that.

Well, alpha versions do go under the numeric URL. Whether we load the
docs at that time or not we can just choose -- but there is no reason
not to. So yeah, that sounds like it would work better.

Can you put your proposal in the form of some logical pseudocode? I
don't understand the free-form description.

Hah, sorry. It's actually Davids proposal, but something like:

if (psql_version_is_numeric)
return /docs/psql_version/
else if (psql_version ends with 'devel')
return /docs/devel/
else
return /docs/{psql_version but with text stripped}/

So that e.g. 12beta would return "12", as would 12rc or 12alpha. But
12devel would return "devel".

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#22David Fetter
david@fetter.org
In reply to: Magnus Hagander (#21)
Re: psql show URL with help

On Thu, Mar 07, 2019 at 11:44:07AM -0800, Magnus Hagander wrote:

On Mon, Mar 4, 2019 at 11:41 PM Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:

On 2019-03-04 17:55, Magnus Hagander wrote:

If the first thing we do when we move from devel to some other state
(beta, RC, etc.) is to publish the docs under the major version
number, then maybe this test should be more along the lines of

looking

for anything that's neither devel nor a number, extract the number,
and use that.

Well, alpha versions do go under the numeric URL. Whether we load the
docs at that time or not we can just choose -- but there is no reason
not to. So yeah, that sounds like it would work better.

Can you put your proposal in the form of some logical pseudocode? I
don't understand the free-form description.

Hah, sorry. It's actually Davids proposal, but something like:

if (psql_version_is_numeric)
return /docs/psql_version/
else if (psql_version ends with 'devel')
return /docs/devel/
else
return /docs/{psql_version but with text stripped}/

So that e.g. 12beta would return "12", as would 12rc or 12alpha. But
12devel would return "devel".

That's exactly what I had in mind :)

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#23Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: David Fetter (#22)
Re: psql show URL with help

On 2019-03-07 23:02, David Fetter wrote:

if (psql_version_is_numeric)
return /docs/psql_version/
else if (psql_version ends with 'devel')
return /docs/devel/
else
return /docs/{psql_version but with text stripped}/

So that e.g. 12beta would return "12", as would 12rc or 12alpha. But
12devel would return "devel".

That's exactly what I had in mind :)

The outcome of that is exactly what my patch does, but the inputs are
different. We have PG_MAJORVERSION, which is always a single integer,
and PG_VERSION, which could be 10.9.8 or 11beta5 or 12devel. The patch does

if (PG_VERSION ends with 'devel')
return /docs/devel/
else
return /docs/$PG_MAJORVERSION/

There is no third case. Your third case of not-numeric-and-not-devel is
correctly covered by the else branch.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#24David Fetter
david@fetter.org
In reply to: Peter Eisentraut (#23)
Re: psql show URL with help

On Fri, Mar 08, 2019 at 01:45:03PM +0100, Peter Eisentraut wrote:

On 2019-03-07 23:02, David Fetter wrote:

if (psql_version_is_numeric)
return /docs/psql_version/
else if (psql_version ends with 'devel')
return /docs/devel/
else
return /docs/{psql_version but with text stripped}/

So that e.g. 12beta would return "12", as would 12rc or 12alpha. But
12devel would return "devel".

That's exactly what I had in mind :)

The outcome of that is exactly what my patch does, but the inputs are
different. We have PG_MAJORVERSION, which is always a single integer,
and PG_VERSION, which could be 10.9.8 or 11beta5 or 12devel. The patch does

if (PG_VERSION ends with 'devel')
return /docs/devel/
else
return /docs/$PG_MAJORVERSION/

There is no third case. Your third case of not-numeric-and-not-devel is
correctly covered by the else branch.

Thanks for helping me understand.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#25Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: David Fetter (#24)
Re: psql show URL with help

On 2019-03-08 16:11, David Fetter wrote:

The outcome of that is exactly what my patch does, but the inputs are
different. We have PG_MAJORVERSION, which is always a single integer,
and PG_VERSION, which could be 10.9.8 or 11beta5 or 12devel. The patch does

if (PG_VERSION ends with 'devel')
return /docs/devel/
else
return /docs/$PG_MAJORVERSION/

There is no third case. Your third case of not-numeric-and-not-devel is
correctly covered by the else branch.

Thanks for helping me understand.

Committed, thanks.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services