Thread: [HACKERS] Potential issue with alter system

[HACKERS] Potential issue with alter system

From
"Joshua D. Drake"
Date:
Folks,

So I did this:

postgres=# alter system set archive_command to 'rsynv -av %p 
postgres@52.3.141.224:/data/archive/%f
';

Note the new line. It properly created in postgresql.auto.conf:

archive_command = 'rsynv -av %p postgres@52.3.141.224:/data/archive/%f
'
(note the new line)

I noticed I spelled rsync wrong and now I get this:

postgres=# alter system set archive_command to 'rsync -av %p 
postgres@52.3.141.224:/data/archive/%f'
;
ERROR:  could not parse contents of file "postgresql.auto.conf"

This is 9.5.2 (Yes, I know... I am in the process of setting up 
replication to 9.5.6 for failover).

JD

-- 
Command Prompt, Inc.                  http://the.postgres.company/                        +1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.
Unless otherwise stated, opinions are my own.



Re: [HACKERS] Potential issue with alter system

From
Tom Lane
Date:
"Joshua D. Drake" <jd@commandprompt.com> writes:
> So I did this:

> postgres=# alter system set archive_command to 'rsynv -av %p
> postgres@52.3.141.224:/data/archive/%f
> ';

> Note the new line. It properly created in postgresql.auto.conf:

> archive_command = 'rsynv -av %p postgres@52.3.141.224:/data/archive/%f
> '
> (note the new line)

Ugh.  That's broken --- we don't support newlines within values in
postgresql.conf files.

[ pokes around ... ]  HEAD seems to reject this properly:

regression=# alter system set archive_command to 'rsynv -av %p postgres@52.3.141.224:/data/archive/%f
regression'# ';
ERROR:  parameter value for ALTER SYSTEM must not contain a newline

> This is 9.5.2 (Yes, I know... I am in the process of setting up
> replication to 9.5.6 for failover).

Ah.  [ digs further... ]  Yup, we fixed that in 9.5.3:

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL9_6_BR [99f3b5613] 2016-04-04 18:05:23 -0400
Branch: REL9_5_STABLE Release: REL9_5_3 [f3d17491c] 2016-04-04 18:05:23 -0400
Branch: REL9_4_STABLE Release: REL9_4_8 [28148e258] 2016-04-04 18:05:24 -0400
   Disallow newlines in parameter values to be set in ALTER SYSTEM.      As noted by Julian Schauder in bug #14063, the
configuration-fileparser   doesn't support embedded newlines in string literals.  While there might   someday be a good
reasonto remove that restriction, there doesn't seem   to be one right now.  However, ALTER SYSTEM SET could accept
strings  containing newlines, since many of the variable-specific value-checking   routines would just see a newline as
whitespace. This led to writing a   postgresql.auto.conf file that was broken and had to be removed manually.
Pendinga reason to work harder, just throw an error if someone tries this.      In passing, fix several places in the
ALTERSYSTEM logic that failed to   provide an errcode() for an ereport(), and thus would falsely log the   failure as
aninternal XX000 error.      Back-patch to 9.4 where ALTER SYSTEM was introduced. 


If you have other entries you want to keep in the postgresql.auto.conf
file, you could get away with manually editing it to remove the newline.
        regards, tom lane



Re: [HACKERS] Potential issue with alter system

From
"Joshua D. Drake"
Date:
On 05/04/2017 12:49 PM, Tom Lane wrote:
> "Joshua D. Drake" <jd@commandprompt.com> writes:
>> So I did this:

>
> If you have other entries you want to keep in the postgresql.auto.conf
> file, you could get away with manually editing it to remove the newline.

Got it. Thanks for digging in. This is actually a very real and easy way 
to explain to people why they need to keep up to date on their dot releases.

Thanks,

JD

>
>             regards, tom lane
>


-- 
Command Prompt, Inc.                  http://the.postgres.company/                        +1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.