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 02:26:37
Message-ID: 200311090226.hA92Qb001378@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I guess you are asking how to get the NumericOnly converted to an oid,
and I see from the code that there are very few places where we allow
oid's to be supplied directly. Most oid's come in as part of our
numberic conversion code.

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.

---------------------------------------------------------------------------

Christopher Kings-Lynne wrote:
> Hi guys,
>
> I've asked this of a few people now, but I haven't managed to get a
> straightforward solution.
>
> I'm working on COMMENT ON LARGE OBJECT.
>
> If you could help me with this one, it would be really cool. Other than
> this, comment on language, conversion, cast and operator class are all done.
>
> This is my grammar snippet. NumericOnly seems to be the one to use -
> that's what CREATE SEQUENCE uses for its large number support, and I
> have to support large OIDs I presume. I could also use IntegerOnly
> perhaps, I don't know:
>
> | COMMENT ON LARGE OBJECT NumericOnly IS comment_text
> {
> CommentStmt *n = makeNode(CommentStmt);
> n->objtype = OBJECT_LARGEOBJECT;
> n->objname = makeList1(makeAConst($5));
> n->objargs = NIL;
> n->comment = $7;
> $$ = (Node *) n;
> }
>
> This is my comment function:
>
> static void
> CommentLargeObject(List *qualname, char *comment)
> {
> /* This is what I cannot figure out - how do I change the Node
> which is the first element in the qualname to an actual Oid type??? */
> Oid loid = somehow_get_oid_from(lfirst(qualname));
> Oid classoid;
>
> /* check that the large object exists */
> if (!LargeObjectExists(loid))
> ereport(ERROR,
> (errcode(ERRCODE_UNDEFINED_OBJECT),
> errmsg("large object %u does not exist", loid)));
>
> classoid = get_system_catalog_relid(LargeObjectRelationName);
>
> CreateComments(loid, classoid, 0, comment);
> }
>
> The problem is extracting the oid from the qualname list. I just can't
> figure it out. I've searched the codebase but there doesn't seem to be
> anywhere else that actually does this, like this.
>
> I've tried all sorts of things, but I can't figure it out...
>
> Thanks for any help,
>
> Chris
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
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

  • Coding help at 2003-10-26 08:38:21 from Christopher Kings-Lynne

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-11-09 02:28:16 Re: Autocomplete <TAB> on Postgres7.4beta5 not working?
Previous Message Kurt Roeckx 2003-11-09 02:24:00 Re: Call for port reports