On 8/6/16 10:13 AM, Bruce Momjian wrote:
> On Sat, Aug 6, 2016 at 04:04:41PM +0100, Andrew Gierth wrote:
>>>>>>> "Bruce" == Bruce Momjian <bruce@momjian.us> writes:
>>
>> Bruce> Would it be helpful to output an array of strings representing
>> Bruce> the index definition?
>>
>> >> Why would that help, if the point is to enable programmatic access
>> >> to information?
>>
>> Bruce> I was thinking an array of strings would avoid problems in
>> Bruce> having to re-scan the output for tokens.
>>
>> OK, but that still leaves the issue of how to interpret each string,
>> yes?
>
> Yes, you still have to parse it, just not scan/tokenize it.
That's an improvement. For some scenarios maybe it's enough. But I also
don't see what's wrong with having the ability to probe for specific
capabilities. I've needed to do this for unit tests, and for some items
it's a real bear.
Trigger definitions are an example. I've done this in the past in unit
tests to ensure that a trigger was defined in a particular way. Some
data is available directly in the catalog, but getting at other info
would have required hard-coding knowledge of specific bit patterns into
the query. Instead of doing that I elected to parse
pg_get_triggerdef[1], but that's hardly satisfying either.
1: https://github.com/decibel/cat_tools/blob/master/sql/cat_tools.sql#L339
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532) mobile: 512-569-9461