Re: Global flag

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Global flag
Дата
Msg-id CAMkU=1zSUpDVtJ-L55sDfO-1SMydLSRQM1R-weBCC+gt0+67dQ@mail.gmail.com
обсуждение исходный текст
Ответ на Global flag  (Swapnil Bhoite <swapnil.temp28@gmail.com>)
Список pgsql-hackers
On Mon, Mar 24, 2014 at 2:53 AM, Swapnil Bhoite <swapnil.temp28@gmail.com> wrote:
Hi,

I want to set a global flag with which I can decide whether to use my code or not
in modified source code.
How I can do that?

edit src/backend/utils/misc/guc.c to add an external variable declaration near "XXX these should appear in other modules' header file", and then add a block for the variable down where it belongs based on the type of the variable, by copying and modifying a related block.  Avoid copying a block with a special validation hook, unless of course you need those.

Then where you want to use it, just add a declaration near the top of the file, and use it where it needs to be used.

Now you can set it the same way you can set other configuration variables.  If the block you copied and changed had "PGC_USERSET", you will be able to change the setting inside each connection dynamically.

It is very easy and powerful once you get used to it.  I find the hardest part is remembering which directory guc.c lives in.

Cheers,

Jeff

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tanmay Deshpande
Дата:
Сообщение: About adding an attribute to pg_attibute
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: psql blows up on BOM character sequence