array_map not SQL accessible?

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: array_map not SQL accessible?
Date: 2009-01-30 17:58:55
Message-ID: 20090130175855.GB3218@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-01-30 18:09:21 Re: How to learn all information on the user of a database?
Previous Message Sam Mason 2009-01-30 17:15:28 Re: using composite types in insert/update