Re: Fwd: Proposal: variant of regclass - Mailing list pgsql-hackers

From Marti Raudsepp
Subject Re: Fwd: Proposal: variant of regclass
Date
Msg-id CABRT9RA9t4vomAgdLoAxv5CgshmfhYpyQrOEum+gTaW=qqx63w@mail.gmail.com
Whole thread Raw
In response to Re: Fwd: Proposal: variant of regclass  (Yugo Nagata <nagata@sraoss.co.jp>)
Responses Re: Fwd: Proposal: variant of regclass  (Yugo Nagata <nagata@sraoss.co.jp>)
List pgsql-hackers
On Tue, Jan 28, 2014 at 10:38 AM, Yugo Nagata <nagata@sraoss.co.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@postgresql.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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: PoC: Partial sort
Next
From: Marti Raudsepp
Date:
Subject: Re: PoC: Partial sort