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

From Pavel Stehule
Subject Re: proposal: function parse_ident
Date
Msg-id CAFj8pRCUeGWtG9NZ1N2GZR42WLpwK4LuoTWgLF4a7n2V14HyXA@mail.gmail.com
Whole thread Raw
In response to Re: proposal: function parse_ident  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: proposal: function parse_ident  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: proposal: function parse_ident  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers


2015-09-08 20:17 GMT+02:00 Corey Huinker <corey.huinker@gmail.com>:

I would have immediate use for this. So often a function is written with a table name as a parameter and it's not immediately clear if the schema is to be parsed out of the string, prescribed, or a separate parameter...in which case the function signature now has a clumsy optional schema parameter somewhere. I've written this bit of code probably five times now, let's make it a solved problem.

text[] return seems most sensible. While I can see the use for a record output, it wouldn't be used as often.

here is a patch

I cannot to use current SplitIdentifierString because it is designed for different purpose - and it cannot to separate non identifier part. But the code is simple - and will be cleaned.

 postgres=# select * from parse_ident('"AHOJ".NAZDAR[]'::text);
┌───────────────┬───────┐
│     parts     │ other │
╞═══════════════╪═══════╡
│ {AHOJ,nazdar} │ []    │
└───────────────┴───────┘
(1 row)


Regards

Pavel

Attachment

pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: ALTER INDEX...SET tab completion
Next
From: "Daniel Verite"
Date:
Subject: Re: [patch] Proposal for \rotate in psql