Re: [PATCHES] WITH DELIMITERS in COPY
От | Gavin Sherry |
---|---|
Тема | Re: [PATCHES] WITH DELIMITERS in COPY |
Дата | |
Msg-id | Pine.LNX.4.21.0204170917300.13432-100000@linuxworld.com.au обсуждение исходный текст |
Ответ на | Re: [PATCHES] WITH DELIMITERS in COPY (Bruce Momjian <pgman@candle.pha.pa.us>) |
Ответы |
Re: [PATCHES] WITH DELIMITERS in COPY
|
Список | pgsql-hackers |
On Tue, 16 Apr 2002, Bruce Momjian wrote: > The code that bothered me about the CREATE DATABASE param processing > was: > > /* process additional options */ > foreach(l, $5) > { > List *optitem = (List *) lfirst(l); > > switch (lfirsti(optitem)) > { > case 1: > n->dbpath = (char *) lsecond(optitem); > break; > case 2: > n->dbtemplate = (char *) lsecond(optitem); > break; > case 3: > n->encoding = lfirsti(lnext(optitem)); > break; > case 4: > n->dbowner = (char *) lsecond(optitem); > break; > } > } > > I see what it is doing, but it seems quite unclear. Seeing that people > are using this as a pattern for other param processing, I will work on a > patch to convert this to DefElem. Wouldn't a few macros clean this up better (ie, make it clearer)? #define CDBOPTDBPATH 1 #define optparam(l) (char *)lsecond(l) #define optparami(l) (int)lfirsti(lnext(l)) foreach(l, $5) { List *optitem = (List *) lfirst(l); switch (lfirsti(optitem)) { case CDBOPTDBPATH: n->dbpath = optparam(optitem); break; ... Regardless, I guess that code is pointless since the consensus seems to be that the use of DefElem is better since it allows for the abstraction of the parameters list. Obviously a good thing if CREATE DATABASE, COPY etc are to be extended often enough. Gavin
В списке pgsql-hackers по дате отправления: