Re: [PATCHES] WITH DELIMITERS in COPY - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCHES] WITH DELIMITERS in COPY
Date
Msg-id 200204162355.g3GNtQW28665@candle.pha.pa.us
Whole thread Raw
In response to Re: [PATCHES] WITH DELIMITERS in COPY  (Gavin Sherry <swm@linuxworld.com.au>)
List pgsql-hackers
Gavin Sherry wrote:
> > 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.
> 

Yes, macros would be the way to go if we didn't have a cleaner
alternative.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: [PATCHES] WITH DELIMITERS in COPY
Next
From: Alvaro Herrera
Date:
Subject: Re: regexp character class locale awareness patch