Re: Extensions, this time with a patch

Dimitri Fontaine <dimitri@2ndquadrant.fr>

From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
To: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Dimitri Fontaine <dimitri@2ndquadrant.fr>, Itagaki Takahiro <itagaki.takahiro@gmail.com>, David Fetter <david@fetter.org>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2010-11-23T08:24:46Z
Lists: pgsql-hackers
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Hmm, the first thought that comes to mind is that the GucContext param
> to ParseConfigFile is unused and can be removed.  This is probably an
> oversight from when include files were introduced in 2006.

Thanks for caring about that part.

> I don't like the fact that this code handles custom_variable_classes
> internally.  I think this would be exposed to the parsing of extension
> control files, which is obviously wrong.

Well, in fact, not that much. The extension code has a special error
case when dealing with custom variables if the class hasn't been already
parsed, and what ParseConfigFile() is doing is pushing the
custom_variable_classes setting in front of the list.

guc-file.l says:
			/*
			 * This variable must be processed first as it controls
			 * the validity of other variables; so it goes at the head
			 * of the result list.  If we already found a value for it,
			 * replace with this one.
			 */

extension.c says:
			ereport(ERROR,
					(errmsg("Unsupported parameter '%s' in file: %s",
							tok1, filename),
					 errhint("Be sure to have 'custom_variable_classes' set "
							 "in a line before any custom variable.")));

So if we don't change the code in ParseConfigFile() that will push
custom_variable_classes in front of the list, all I have to change in
the extension.c file is the error message.

I fail to see a future usage of custom_variable_classes where it
wouldn't help to have that in the list before any user setting that
depends on it.

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support