Global flag

Started by Swapnil Bhoitealmost 12 years ago3 messages
#1Swapnil Bhoite
swapnil.temp28@gmail.com

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?

Thank you
-Swapnil

#2Jeff Janes
jeff.janes@gmail.com
In reply to: Swapnil Bhoite (#1)
Re: Global flag

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

#3Craig Ringer
craig@2ndquadrant.com
In reply to: Swapnil Bhoite (#1)
Re: Global flag

On 03/24/2014 05:53 PM, Swapnil Bhoite 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?

Please reply to existing mailing list threads. Don't make a new message
for every post. It's confusing and causes people to loose track of what
others have already told you.

Reply-all to somebody's reply to your original message (or reply-list,
if your mail client supports it) if you're following up on an existing
topic.

Imagine it like a forum. You don't make a new thread for every post, do
you? No, you *reply* to an existing thread.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers