Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])
От | Amit Kapila |
---|---|
Тема | Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review]) |
Дата | |
Msg-id | 004c01ce8761$b8a4ab20$29ee0160$@kapila@huawei.com обсуждение исходный текст |
Ответ на | Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review]) (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
> On Tuesday, July 23, 2013 5:26 AM Tom Lane wrote: > Josh Berkus <josh@agliodbs.com> writes: > > Christophe just discovered something with include files which is > going > > to cause issues with ALTER SYSTEM SET. > > > So, take as a hypothetical that you use the default postgresql.conf > > file, which sets shared_buffers = 32MB. > > > Instead of editing this file, you do ALTER SYSTEM SET shared_buffers > = > > '1GB', which updates config/postgresql.auto.conf. > > > Then you restart PostgreSQL. > > > Everything is hunky-dory, until a later occasion where you *reload* > > postgresql. > > Everything was already *not* hunky-dory as soon as you did that, since > a SIGHUP would have had the same problem. > > I'd be inclined to think that ALTER SYSTEM SET should not be allowed to > modify any PGC_POSTMASTER parameters. One way to fix the problem is that while parsing if the option already exists, replace it. Something like below code ParseConfigFp() { .. .. /* replace the option value, if already exists in list */ for (item = *head_p; item != NULL; item= item->next) { if (strcmp(item->name, opt_name) == 0) { pfree(item->value); item->value= pstrdup(opt_value); replaced = true; break; } } if(!replaced) { /* ordinary variable, append to list */ item =palloc(sizeof *item); item->name = opt_name; item->value =opt_value; item->filename = pstrdup(config_file); item->sourceline= ConfigFileLineno-1; item->next = NULL; if(*head_p == NULL) *head_p = item; else (*tail_p)->next = item; *tail_p = item; } .. .. } There is overhead of traversing the list each time, but as this path is traversed in less and non-performance critical operations, it can be considered to fix the problem. If you consider above as a non-trivial or not a right way to fix the problem, then I can update the patch to disallow PGC_POSTMASTER parameters by ALTER SYSTEM SET command. With Regards, Amit Kapila.
В списке pgsql-hackers по дате отправления: