Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]

From: Amit kapila <amit(dot)kapila(at)huawei(dot)com>
To: "zb(at)cybertec(dot)at" <zb(at)cybertec(dot)at>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'Robert Haas'" <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]
Date: 2013-01-18 10:05:26
Message-ID: 6C0B27F7206C9E4CA54AE035729E9C383BEB611A@szxeml509-mbx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Monday, January 14, 2013 6:48 PM Boszormenyi Zoltan wrote:
2013-01-14 07:47 keltezéssel, Amit kapila írta:
> On Sunday, January 13, 2013 2:45 PM Boszormenyi Zoltan wrote:
> 2013-01-13 05:49 keltezéssel, Amit kapila írta:
>> On Sunday, January 13, 2013 12:41 AM Tom Lane wrote:
>> Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:

>>>> I can think of below ways to generate tmp file
>>>> 1. Generate session specific tmp file name during operation. This will
be similar to what is
>>>> currently being done in OpenTemporaryFileinTablespace() to
generate a tempfilename.
>>>> 2. Generate global tmp file name. For this we need to maintain global
counter.
>>>> 3. Always generate temp file with same name "postgresql.auto.conf.tmp",
as at a time only one
>>>> session is allowed to operate.
>>> What's wrong with mkstemp("config_dir/postgresql.auto.conf.XXXXXX")
>>> that returns a file descriptor for an already created file with a
unique name?
>> I think for Windows exactly same behavior API might not exist, we might
need to use GetTempFileName.
>> It will generate some different kind of name, which means cleanup also
need to take care of different kind of names.
>> So if this is right, I think it might not be very appropriate to use it.

> In that case (and also because the LWLock still serialize the whole
procedure)
> you can use GetTempFileName() on Windows and tempnam(3) for non-Windows.
> GetTempFileName() and tempnam() return the constructed temporary file name
> out of the directory and the filename prefix components.

On using mktemp, linux compilation gives below warning
warning: the use of `mktemp' is dangerous, better use `mkstemp'

So I planned to use mkstemp.

In Windows, there is an api _mktemp_s, followed by open call, behaves in a similar way as mkstemp available in linux.
The code is changed to use of mkstemp functionality to generate a unique temporary file name instead of .lock file.
Please check this part of code, I am not very comfortable with using this API.

Removed the code which is used for deleting the .lock file in case of backend crash or during server startup.

Added a new function RemoveAutoConfTmpFiles used for deleting the temp files left out any during previous
postmaster session in the server startup.

In SendDir(), used sizeof() -1

With Regards,
Amit Kapila.

Attachment Content-Type Size
set_persistent_v5.patch application/octet-stream 58.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-01-18 10:15:53 Passing connection string to pg_basebackup
Previous Message Albe Laurenz 2013-01-18 09:47:00 Re: Starting Postgres : user from same group