Re: Global flag

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Swapnil Bhoite <swapnil(dot)temp28(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Global flag
Date: 2014-03-24 17:54:07
Message-ID: CAMkU=1zSUpDVtJ-L55sDfO-1SMydLSRQM1R-weBCC+gt0+67dQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 24, 2014 at 2:53 AM, Swapnil Bhoite <swapnil(dot)temp28(at)gmail(dot)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

In response to

  • Global flag at 2014-03-24 09:53:02 from Swapnil Bhoite

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2014-03-24 18:50:21 Re: psql blows up on BOM character sequence
Previous Message Tanmay Deshpande 2014-03-24 17:44:34 About adding an attribute to pg_attibute