From: | Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCHES] WITH DELIMITERS in COPY |
Date: | 2002-04-16 23:56:03 |
Message-ID: | Pine.LNX.4.21.0204170917300.13432-100000@linuxworld.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2002-04-17 00:03:41 | Re: regexp character class locale awareness patch |
Previous Message | Bruce Momjian | 2002-04-16 23:55:25 | Re: [PATCHES] WITH DELIMITERS in COPY |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-04-17 02:10:37 | Re: ANSI Compliant Inserts |
Previous Message | Bruce Momjian | 2002-04-16 23:55:25 | Re: [PATCHES] WITH DELIMITERS in COPY |