Re: Fwd: Proposal: variant of regclass

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>, Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pavel Golub <pavel(at)gf(dot)microolap(dot)com>, Pavel Golub <pavel(at)microolap(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Pavel Stěhule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: Fwd: Proposal: variant of regclass
Date: 2014-02-06 19:25:01
Message-ID: CABRT9RA9t4vomAgdLoAxv5CgshmfhYpyQrOEum+gTaW=qqx63w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 28, 2014 at 10:38 AM, Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:
> I revised the patch. Could you please review this?

I didn't test the patch due to the duplicate OID compilation error.
But a few things stuck out from the diffs:
* You added some unnecessary spaces at the beginning of the linein
OpernameGetCandidates.
* regclass_guts and regtype_guts can be simplified further by moving
the ereport() code into regclassin, thereby saving the "if
(missing_ok)"
* I would rephrase the documentation paragraph as:

to_regclass, to_regproc, to_regoper and to_regtype are functions
similar to the regclass, regproc, regoper and regtype casts, except
that they return InvalidOid (0) when the object is not found, instead
of raising an error.

On Wed, Jan 22, 2014 at 1:04 PM, Tatsuo Ishii <ishii(at)postgresql(dot)org> wrote:
>> I thought the consensus was that returning NULL is better than
>> InvalidOid? From an earlier message:

> Not sure. There's already at least one counter example:
>
> pg_my_temp_schema() oid OID of session's temporary schema, or 0 if none

And there are pg_relation_filenode, pg_stat_get_backend_dbid,
pg_stat_get_backend_userid which return NULL::oid. In general I don't
like magic values like 0 in SQL. For example, this query would give
unexpected results because InvalidOid has some other meaning:

select * from pg_aggregate where aggfinalfn=to_regproc('typo');

Regards,
Marti

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marti Raudsepp 2014-02-06 19:32:50 Re: PoC: Partial sort
Previous Message Robert Haas 2014-02-06 19:15:39 Re: PoC: Partial sort