Re: Coding help

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Coding help
Date: 2003-11-09 14:12:46
Message-ID: 200311091412.hA9ECka07802@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Christopher Kings-Lynne wrote:
>
> > The only idea I have is to call oidin() to do the conversion from string
> > to oid. I see this in copy.c:
> >
> > loaded_oid = DatumGetObjectId(DirectFunctionCall1(oidin,
> > CStringGetDatum(string)));
> > if (loaded_oid == InvalidOid)
> > ereport(ERROR,
> > (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
> > errmsg("invalid OID in COPY data")));
> >
> > I would give that a try.
>
> Yes but in this case, the Node is parsed like this:
>
> | COMMENT ON LARGE OBJECT NumericOnly IS comment_text
> {
>
> ...
>
>
> n->objname = makeList1(makeAConst($5));
>
> ...
>
> $$ = (Node *) n;
> }
>
> So there is no CString to convert to a Datum...

But I see makeAConst as:

static Node *
makeAConst(Value *v)
{
Node *n;

switch (v->type)
{
case T_Float:
n = makeFloatConst(v->val.str);
break;

case T_Integer:
n = makeIntConst(v->val.ival);
break;

case T_String:
default:
n = makeStringConst(v->val.str, NULL);
break;
}

return n;
}

which uses makeStringConst().

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-11-09 15:10:06 Re: Coding help
Previous Message Bruce Momjian 2003-11-09 14:05:11 Re: [HACKERS] BEGIN vs START TRANSACTION