On Mon, Oct 6, 2014 at 7:03 PM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
> On 10/4/14, 8:12 PM, Robert Haas wrote:
>>> >It's just not sane to try to parse such text strings.
>>
>> But this is a pretty ridiculous argument. We have an existing parser
>> that does it just fine, and a special-purpose parser that does just
>> that (and not all of the other stuff that the main parser does) would
>> be a great deal simpler. Maybe there are examples other than the ones
>> you listed here that demonstrate that this is actually a hard problem,
>> but the fact that you might need to undo quote_literal() or search for
>> and split on fixed strings does not.
>
>
> FWIW, I've run into situations more than once in userspace where I need a
> way to properly separate schema and object name. Generally I can make do
> using reg* casts and then hitting catalog tables, but it'd be nice if there
> was an easier way.
Sure, although I think that's a bit of a separate problem. It's hard
to iterate through a string a character at a time from the SQL level
so that you can handle stuff like the quote_literal() rules. If we
want people to be able to do that easily we need to provide tools to
handle it. But C is actually quite well-suited to such tasks.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company