On 2013-02-25 22:15:33 +0100, Andres Freund wrote:
> Currently guc-file.c allows the following as guc names:
> 
> ID            {LETTER}{LETTER_OR_DIGIT}*
> QUALIFIED_ID  {ID}"."{ID}
> 
> That is either one token starting with a letter followed by numbers or
> letters or exactly two of those separated by a dot.
> Those restrictions are existing for neither SET/set_config() via SQL nor
> for postgres -c styles of setting options.
> 
> I propose loosening those restrictions to
> a) allow repeatedly qualified names like a.b.c
> b) allow variables to start with a digit from the second level onwards.

The attached patch does a) but not b) as Tom argued it's not allowed in
a plain fashion in SQL either. There you need to quote the variable name.

> Additionally, should we perhaps enforce the same rules for -c and
> set_config()/SET?

The discussion seems to have concluded that this isn't neccessary, so I
haven't included this.

The patch still is pretty trivial - I've looked around and I really
didn't see anything else that requires changes. I haven't even found
documentation to adapt.

Greetings,

Andres Freund

-- 
 Andres Freund                     http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
>From 9fa69ccc79c7bc42be554bc3f4e740c4e77d50d7 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Sat, 14 Sep 2013 23:15:10 +0200
Subject: [PATCH] Allow custom GUCs to be nested more than one level in config
 files

Doing so was allowed via SET, postgres -c and set_config()
before. Allowing to do so is useful for grouping together variables
inside an extension's toplevel namespace.

There still are differences in the accepted variable names between the
different methods of setting GUCs after this commit, but the concensus
is that those are acceptable.
---
 src/backend/utils/misc/guc-file.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index b730a12..ff4202d 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -78,7 +78,7 @@ LETTER			[A-Za-z_\200-\377]
 LETTER_OR_DIGIT [A-Za-z_0-9\200-\377]
 
 ID				{LETTER}{LETTER_OR_DIGIT}*
-QUALIFIED_ID	{ID}"."{ID}
+QUALIFIED_ID	{ID}("."{ID})+
 
 UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])*
 STRING			\'([^'\\\n]|\\.|\'\')*\'
-- 
1.8.4.21.g992c386.dirty

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

Reply via email to