Re: proposal: function parse_ident - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: function parse_ident
Date
Msg-id CAFj8pRA6qdNrjNNy09WZFHwPwV4WzjbKDXLWy-zV1Fvpyt1EYg@mail.gmail.com
Whole thread Raw
In response to Re: proposal: function parse_ident  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: proposal: function parse_ident  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List pgsql-hackers
Hi

2015-08-19 21:33 GMT+02:00 Tom Lane <tgl@sss.pgh.pa.us>:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I miss a functionality that helps with parsing any identifier to basic
> three parts - database, schema, objectname. We have this function
> internally, but it is not available for SQL layer.

> FUNCTION parse_ident(IN ident text, OUT dbname text, OUT schemaname text,
> OUT objectname text)

What exactly would you do with this that would not be better done with,
for example, regclass?

Don't say "parse names for things other than tables".  Only a minority
of the types of objects used in the database have names that meet this
specification.

I see one important reason and one minor reason:

Important - cast to regclass is possible only for existing objects - parse_ident doesn't check validity of parsed ident.
minor - cast to regclass depends on search_path - but parse_ident not - with this function I am able to detect if ident depends (or not) on search_path.

Regards

Pavel

 

                        regards, tom lane

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal: function parse_ident
Next
From: Marc Mamin
Date:
Subject: Re: Declarative partitioning