Re: Coding help - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Coding help
Date
Msg-id 200311091412.hA9ECka07802@candle.pha.pa.us
Whole thread Raw
In response to Re: Coding help  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List 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@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: Coding help
Next
From: Tom Lane
Date:
Subject: Re: Coding help