array_map not SQL accessible? - Mailing list pgsql-hackers

From Alvaro Herrera
Subject array_map not SQL accessible?
Date
Msg-id 20090130175855.GB3218@alvh.no-ip.org
Whole thread Raw
Responses Re: array_map not SQL accessible?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

I'm wondering why don't we expose the array_map() function to the SQL
level.  As it happens, I need to use it in the pg_dump support for TOAST
reloptions.

Why?  Well, TOAST reloptions are stored in the pg_class tuple of the
TOAST table, so when I extract them directly, it looks like a simple
array of normally-named reloptions.  Like this:

alvherre=# select c.oid,c.relname, c.reloptions, tc.reloptions
alvherre-# from pg_class c join pg_class tc on c.reltoastrelid = tc.oid
alvherre-# where c.relname = 'foo'; oid  | relname |   reloptions    |   reloptions    
-------+---------+-----------------+-----------------48372 | foo     | {fillfactor=10} | {fillfactor=15}
(1 fila)

So I need the second array to look like this instead:

toast.fillfactor=15

The easiest way to do that that I can see is using array_map and a
function that prepends "toast." to each element.

So, can I just go ahead and try to expose it for this usage?

-- 
Alvaro Herrera                 http://www.amazon.com/gp/registry/CTMLCN8V17R4
You liked Linux a lot when he was just the gawky kid from down the block
mowing your lawn or shoveling the snow. But now that he wants to date
your daughter, you're not so sure he measures up. (Larry Greenemeier)


pgsql-hackers by date:

Previous
From: Fernando Ike
Date:
Subject: [PATCH] Psql List Languages
Next
From: Robert Haas
Date:
Subject: Re: How to learn all information on the user of a database?