From: | Dimitri Fontaine <dim(at)dalibo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Markus Schiltknecht <markus(at)bluegap(dot)ch> |
Subject: | Re: Large Object to Bytea Conversion |
Date: | 2006-11-14 13:45:35 |
Message-ID: | 200611141445.37926.dim@dalibo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
Le mardi 14 novembre 2006 14:36, Markus Schiltknecht a écrit :
> I want to convert some large objects to bytea fields on the server.
> Searching through the documentation didn't reveal any hints. Am I
> missing something or is there really no such thing as a
> lo_convert_to_bytea function?
You may want to try this code given on IRC by i-can't-remember-who:
CREATE FUNCTION _phpads_agg_concat (bytea, bytea) RETURNS bytea AS $_$SELECT
$1 || $2$_$ LANGUAGE sql IMMUTABLE STRICT;
CREATE AGGREGATE phpads_agg_concat (bytea) (SFUNC = _phpads_agg_concat, STYPE
= bytea, INITCOND = '');
EXPLAIN ANALYZE SELECT phpads_agg_concat(data) FROM (SELECT data FROM
pg_largeobject WHERE loid = 24513361 ORDEY BY pageno) t;
QUERY
PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=10.62..10.63 rows=1 width=32) (actual time=4.682..4.685
rows=1 loops=1)
-> Index Scan using pg_largeobject_loid_pn_index on pg_largeobject
(cost=0.00..10.57 rows=4 width=1863) (actual time=0.075..0.162 rows=4
loops=1)
Index Cond: (loid = 24513361::oid)
Total runtime: 5.146 ms
CREATE FUNCTION phppgads_lo_readall(oid) RETURNS bytea AS $_$SELECT
phpads_agg_concat(data) FROM (SELECT data FROM pg_largeobject WHERE loid = $1
ORDEY BY pageno) t$_$ LANGUAGE sql STRICT;
Hope this will help,
--
Dimitri Fontaine
http://www.dalibo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Markus Schiltknecht | 2006-11-14 13:52:41 | Re: Large Object to Bytea Conversion |
Previous Message | Markus Schiltknecht | 2006-11-14 13:36:44 | Large Object to Bytea Conversion |