Thread: small windows psqlrc re-wording

small windows psqlrc re-wording

From
Robert Treat
Date:
Howdy folks,

The attached patch tweaks the wording around finding the psqlrc file
on windows, with the primary goal of removing the generally incorrect
statement that windows has no concept of a home directory.

Robert Treat
https://xzilla.net

Attachment

Re: small windows psqlrc re-wording

From
Julien Rouhaud
Date:
Hi,

On Wed, Jul 27, 2022 at 02:42:11PM -0400, Robert Treat wrote:
>
> The attached patch tweaks the wording around finding the psqlrc file
> on windows, with the primary goal of removing the generally incorrect
> statement that windows has no concept of a home directory.

Windows only has a concept of home directory since Vista, so that used to be
true.

Anyway, since we don't support XP or anything older since about 3 weeks ago
(495ed0ef2d72a6a74def296e042022479d5d07bd), +1 for the patch.



Re: small windows psqlrc re-wording

From
Tom Lane
Date:
Julien Rouhaud <rjuju123@gmail.com> writes:
> On Wed, Jul 27, 2022 at 02:42:11PM -0400, Robert Treat wrote:
>> The attached patch tweaks the wording around finding the psqlrc file
>> on windows, with the primary goal of removing the generally incorrect
>> statement that windows has no concept of a home directory.

> Windows only has a concept of home directory since Vista, so that used to be
> true.
> Anyway, since we don't support XP or anything older since about 3 weeks ago
> (495ed0ef2d72a6a74def296e042022479d5d07bd), +1 for the patch.

If all supported versions do have home directories now, should we
instead think about aligning the Windows behavior with everywhere
else?

            regards, tom lane



Re: small windows psqlrc re-wording

From
Julien Rouhaud
Date:
On Thu, Jul 28, 2022 at 10:04:12AM -0400, Tom Lane wrote:
> Julien Rouhaud <rjuju123@gmail.com> writes:
> > On Wed, Jul 27, 2022 at 02:42:11PM -0400, Robert Treat wrote:
> >> The attached patch tweaks the wording around finding the psqlrc file
> >> on windows, with the primary goal of removing the generally incorrect
> >> statement that windows has no concept of a home directory.
>
> > Windows only has a concept of home directory since Vista, so that used to be
> > true.
> > Anyway, since we don't support XP or anything older since about 3 weeks ago
> > (495ed0ef2d72a6a74def296e042022479d5d07bd), +1 for the patch.
>
> If all supported versions do have home directories now, should we
> instead think about aligning the Windows behavior with everywhere
> else?

As far as I know the expected usage on Windows is still different.  Even with
home directories application are still expected to put stuff in %APPDATA% (1),
in a dedicated directory.  That's especially important since there is still no
concept of "hidden" files and the explorer still hides the extensions by
default.  I can however see that having a file named ".something" is now mostly
working, which IIRC wasn't really the case the last time I used Windows (around
XP).

[1] https://en.wikipedia.org/wiki/Special_folder#File_system_directories



Re: small windows psqlrc re-wording

From
Tom Lane
Date:
Julien Rouhaud <rjuju123@gmail.com> writes:
> On Thu, Jul 28, 2022 at 10:04:12AM -0400, Tom Lane wrote:
>> If all supported versions do have home directories now, should we
>> instead think about aligning the Windows behavior with everywhere
>> else?

> As far as I know the expected usage on Windows is still different.  Even with
> home directories application are still expected to put stuff in %APPDATA% (1),
> in a dedicated directory.  That's especially important since there is still no
> concept of "hidden" files and the explorer still hides the extensions by
> default.

Ah.  Yeah, if there's no convention about hiding files based on a
leading "." then we definitely don't want to do that.

            regards, tom lane



Re: small windows psqlrc re-wording

From
Tom Lane
Date:
After looking at the text more carefully, I thought it could use
a deal more help than Robert has given it.  I propose the attached.

            regards, tom lane

diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 186f8c506a..f8112c1500 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -4892,21 +4892,23 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
      commands.
     </para>
     <para>
-     The system-wide startup file is named <filename>psqlrc</filename> and is
+     The system-wide startup file is named <filename>psqlrc</filename>.
+     By default it is
      sought in the installation's <quote>system configuration</quote> directory,
      which is most reliably identified by running <literal>pg_config
-     --sysconfdir</literal>.  By default this directory will be <filename>../etc/</filename>
+     --sysconfdir</literal>.
+     Typically this directory will be <filename>../etc/</filename>
      relative to the directory containing
-     the <productname>PostgreSQL</productname> executables.  The name of this
-     directory can be set explicitly via the <envar>PGSYSCONFDIR</envar>
-     environment variable.
+     the <productname>PostgreSQL</productname> executables.
+     The directory to look in can be set explicitly via
+     the <envar>PGSYSCONFDIR</envar> environment variable.
     </para>
     <para>
      The user's personal startup file is named <filename>.psqlrc</filename>
-     and is sought in the invoking user's home directory.  On Windows, which
-     lacks such a concept, the personal startup file is named
+     and is sought in the invoking user's home directory.  On Windows
+     the personal startup file is instead named
      <filename>%APPDATA%\postgresql\psqlrc.conf</filename>.
-     The location of the user's startup file can be set explicitly via
+     In either case, this default file name can be overridden by setting
      the <envar>PSQLRC</envar> environment variable.
     </para>
     <para>
@@ -4914,10 +4916,12 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
      can be made <application>psql</application>-version-specific
      by appending a dash and the <productname>PostgreSQL</productname>
      major or minor release number to the file name,
-     for example <filename>~/.psqlrc-9.2</filename> or
-     <filename>~/.psqlrc-9.2.5</filename>.  The most specific
+     for example <filename>~/.psqlrc-15</filename> or
+     <filename>~/.psqlrc-15.2</filename>.  The most specific
      version-matching file will be read in preference to a
      non-version-specific file.
+     These version suffixes are added after determining the file name
+     as explained above.
     </para>
    </listitem>
   </varlistentry>

Re: small windows psqlrc re-wording

From
Julien Rouhaud
Date:
On Wed, Sep 07, 2022 at 01:10:11PM -0400, Tom Lane wrote:
> After looking at the text more carefully, I thought it could use
> a deal more help than Robert has given it.  I propose the attached.

It looks good to me.

-     for example <filename>~/.psqlrc-9.2</filename> or
-     <filename>~/.psqlrc-9.2.5</filename>.  The most specific
+     for example <filename>~/.psqlrc-15</filename> or
+     <filename>~/.psqlrc-15.2</filename>.  The most specific

This bit is a bit saddening.  It's probably good to switch to the new 2 digits
versioning but not trying to maintain it any further right?

That being said, should the patch mention versions that at least currently
exist, like -14 and -14.5?



Re: small windows psqlrc re-wording

From
Tom Lane
Date:
Julien Rouhaud <rjuju123@gmail.com> writes:
> On Wed, Sep 07, 2022 at 01:10:11PM -0400, Tom Lane wrote:
> -     for example <filename>~/.psqlrc-9.2</filename> or
> -     <filename>~/.psqlrc-9.2.5</filename>.  The most specific
> +     for example <filename>~/.psqlrc-15</filename> or
> +     <filename>~/.psqlrc-15.2</filename>.  The most specific

> This bit is a bit saddening.  It's probably good to switch to the new 2 digits
> versioning but not trying to maintain it any further right?

It occurred to me later to substitute &majorversion; and &version;
like this:

+     for example <filename>~/.psqlrc-&majorversion;</filename> or
+     <filename>~/.psqlrc-&version;</filename>.  The most specific

On testing that in HEAD, I read

    Both the system-wide startup file and the user's personal startup file
    can be made psql-version-specific by appending a dash and the
    PostgreSQL major or minor release number to the file name, for example
    ~/.psqlrc-16 or ~/.psqlrc-16devel.

That's a little confusing but it's actually accurate, because what
process_psqlrc_file appends is the string PG_VERSION, so in a devel
branch or beta release there's a non-numeric "minor release".
I'm inclined to go ahead and do it like that.

            regards, tom lane



Re: small windows psqlrc re-wording

From
Tom Lane
Date:
I wrote:
> On testing that in HEAD, I read

>     Both the system-wide startup file and the user's personal startup file
>     can be made psql-version-specific by appending a dash and the
>     PostgreSQL major or minor release number to the file name, for example
>     ~/.psqlrc-16 or ~/.psqlrc-16devel.

> That's a little confusing but it's actually accurate, because what
> process_psqlrc_file appends is the string PG_VERSION, so in a devel
> branch or beta release there's a non-numeric "minor release".
> I'm inclined to go ahead and do it like that.

I decided that what I found jarring about that was the use of "release
number" with a non-numeric version, so I changed it to "release
identifier" and pushed.

            regards, tom lane



Re: small windows psqlrc re-wording

From
Robert Treat
Date:
On Fri, Sep 9, 2022 at 1:52 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> I wrote:
> > On testing that in HEAD, I read
>
> >     Both the system-wide startup file and the user's personal startup file
> >     can be made psql-version-specific by appending a dash and the
> >     PostgreSQL major or minor release number to the file name, for example
> >     ~/.psqlrc-16 or ~/.psqlrc-16devel.
>
> > That's a little confusing but it's actually accurate, because what
> > process_psqlrc_file appends is the string PG_VERSION, so in a devel
> > branch or beta release there's a non-numeric "minor release".
> > I'm inclined to go ahead and do it like that.
>
> I decided that what I found jarring about that was the use of "release
> number" with a non-numeric version, so I changed it to "release
> identifier" and pushed.
>

Looks good. Thanks Tom / Julien.


Robert Treat
https://xzilla.net