Adding new variables into GUC

Started by Θάνος Παπαπέτρουalmost 15 years ago5 messages

Hi,

I am an MSc student in the department of Informatics and
Telecommunications of the University of Athens and as part of my
thesis I am examining a new path/plan cost model for DB optimizers. I
have successfully changed the optimizer of PostgreSQL in order to
implement this model, but I have stumbled upon a very little detail:
until now I use some hardcoded values in my code which I would like to
make accessible through GUC. After much googling the only relative
pages I have found are about configuring existing PostgreSQL variables
and src/backend/utils/misc/README does not mention anything about
adding new vars. Can anybody please provide some help?

I presume I have to add new entries in ConfigureNames* arrays in src/
backend/utils/misc/guc.c, but I am not sure about the field values of
config_* structs I have to enter. Also is there any "standard"
location where the actual variables should be declared, or I can
freely declare them in any source file (the source file that actually
uses them)? Do I have to declare a config_generic struct too? How do I
specify boot values?

Thanks in advance,

Thanos Papapetrou

Θάνος Παπαπέτρου

You insist that there is something that a machine can't do. If you
will tell me precisely what it is that a machine cannot do, then I can
always make a machine which will do just that.

P.S.: I initially posted this message in pgsql-generic, but after
thinking about it more I believe this is the most appropriate list, so
I re-posted here.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Θάνος Παπαπέτρου (#1)
Re: Adding new variables into GUC

=?ISO-8859-7?B?yNzt7/Ig0OHw4fDd9PHv9Q==?= <thanos@di.uoa.gr> writes:

I am an MSc student in the department of Informatics and
Telecommunications of the University of Athens and as part of my
thesis I am examining a new path/plan cost model for DB optimizers. I
have successfully changed the optimizer of PostgreSQL in order to
implement this model, but I have stumbled upon a very little detail:
until now I use some hardcoded values in my code which I would like to
make accessible through GUC. After much googling the only relative
pages I have found are about configuring existing PostgreSQL variables
and src/backend/utils/misc/README does not mention anything about
adding new vars. Can anybody please provide some help?

You basically need the variable, the entry in the appropriate array in
guc.c, and some documentation (at least if you'd like anyone else to
ever use the code). Try looking at some past patches that added GUCs
similar to yours.

regards, tom lane

#3Josh Berkus
josh@agliodbs.com
In reply to: Tom Lane (#2)
Re: Adding new variables into GUC

You basically need the variable, the entry in the appropriate array in
guc.c, and some documentation (at least if you'd like anyone else to
ever use the code). Try looking at some past patches that added GUCs
similar to yours.

For completeness, it would also be good to add rows to the pg_settings
system catalog, but that's not necessary for testing.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com

#4Robert Haas
robertmhaas@gmail.com
In reply to: Josh Berkus (#3)
Re: Adding new variables into GUC

2011/2/10 Josh Berkus <josh@agliodbs.com>:

You basically need the variable, the entry in the appropriate array in
guc.c, and some documentation (at least if you'd like anyone else to
ever use the code).  Try looking at some past patches that added GUCs
similar to yours.

For completeness, it would also be good to add rows to the pg_settings
system catalog, but that's not necessary for testing.

pg_settings doesn't need to be separately updated. It's just a view.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Berkus (#3)
Re: Adding new variables into GUC

Josh Berkus <josh@agliodbs.com> writes:

You basically need the variable, the entry in the appropriate array in
guc.c, and some documentation (at least if you'd like anyone else to
ever use the code). Try looking at some past patches that added GUCs
similar to yours.

For completeness, it would also be good to add rows to the pg_settings
system catalog, but that's not necessary for testing.

Huh? pg_settings is a dynamically generated view.

regards, tom lane