Re: MDB - Delete LOB

From: Date: Mon, 09 Jun 2003 10:33:42 +0000
Subject: Re: MDB - Delete LOB
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17194@lists.php.net to get a copy of this message
Hi all, regard the suggestion about binary string, I agree with Alexey that it could be an interesting alternatives to LOB. I can't use Oracle for my project, so... ok, I'll try. Anyway, following the Lukas first post, I wrote a MDB pgsql specific method for a delete query involving LOB (method in attach). delete_lob_query($query, $lob_field) You have to pass your delete query and the field name in which oid(s) are stored, and the method delete the row and the LOB (I've tested the method for a while and it works, but I think the error handling should be checked, because my knowledge of MDB is still poor) OK, a specific pgsql method it's not an elegant solution, as already posted, but... I submit my code to Lukas! The only restriction of this method is when in table definition there is a 'cascade on delete'. In such case, I think, my method doesn't work ('cause it's not possible a select cascade, nor a cursor on delete - or at list I'm not able to!). For this reason, the ultimate solution to this problem seems to me involving a trigger. It'a a database problem, try to solve it directly in database (and leave the api clean)!! Someting like this definitly work, even with cascade <SQL> CREATE FUNCTION delete_oid() RETURNS TRIGGER AS ' BEGIN DELETE FROM pg_largeobject where loid = OLD.your_oid_field; RETURN NULL; END; ' LANGUAGE 'plpgsql'; CREATE TRIGGER delete_oid AFTER DELETE ON your_table FOR EACH ROW EXECUTE PROCEDURE delete_oid(); </SQL> Only one drawback... the delete on a system table (pg_largeobject) is permitted only for postgres super-user... I hope it could help Davide PJ Caironi -- PJ "Alexey Borzov" <borz_off@cs.msu.su> wrote in message news:3EE4466B.8010002@cs.msu.su... > Hi! > > Manuel Lemos wrote: > >> Maybe you can get rid of LOBs and just use the bytea fields? > > > > Binary strings are not suitable as large objects containers because you > > have to paste their whole contents in the query that creates or updated > > them. This means if it would not exceed your PHP memory limit, it would > > probably crash your Web server processes when you tried to insert large > > data. > > > > ... > > > > Although PostgreSQL objects are not perfect, I think they are better to > > store large objects than having to deal with the problems of pasting > > large data in SQL queries. > > That's why I wrote 'maybe' in my post. ;] > The consensus can be that if the author of the original message does not > need to store binary data larger than few megabytes AND does not need to > have some kind of random access to it, then he can use binary strings. > If that is not true, he will have to use LOB API. > begin 666 pgsql.patch.php M("\O('U]?0T*(" @("\O('M[>R!D96QE=&5?;&]B7W%U97)Y*"D-"@T*(" @ M("\J*@T*(" @(" J(%-E;F0@82!D96QE=&4@<75E<GD@:6YV;VQV:6YG($Q/ M0B!T;R!T:&4@9&%T86)A<V4N( T*(" @(" J#0H@(" @("H@0'!A<F%M('-T M<FEN9R D<75E<GD@=&AE(%-13"!Q=65R>0T*(" @(" J($!P87)A;2!A<G)A M>2 D;&]B7V9I96QD(&YA;64@;V8@=&AE(&9I96QD('-T;W)I;F<@=&AE($]) M1" -"B @(" @*B! <F5T=7)N(&UI>&5D($U$0E]O:R!O<B!-1$)?97)R;W(- M"B @(" @*B! 86-C97-S('!U8FQI8PT*(" @(" J*B\-"B @("!F=6YC=&EO M;B!D96QE=&5?;&]B7W%U97)Y*"1Q=65R>2P@)&QO8E]F:65L9#UN=6QL*0T* M(" @('L-"B @(" @(" @:68H)&QO8E]F:65L9" ]/2!N=6QL*7L-"B @(" @ M(" @(" @(')E='5R;B@D=&AI<RT^<F%I<V5%<G)O<BA-1$)?15)23U(I*3L- M"B @(" @(" @?0T*(" @(" @(" D=&AI<RT^9&5B=6<H)U%U97)Y.B D<75E M<GDG*3L-"B @(" @(" @)&ES;6%N:7 @/2!-1$(Z.FES36%N:7 H)'%U97)Y M*3L-"B @(" @(" @)&-O;FYE8W1E9" ]("1T:&ES+3YC;VYN96-T*"D[#0H@ M(" @(" @(&EF("A-1$(Z.FES17)R;W(H)&-O;FYE8W1E9"DI('L-"B @(" @ M(" @(" @(')E='5R;B@D8V]N;F5C=&5D*3L-"B @(" @(" @?0T*(" @(" @ M(" D;6]D7W%U97)Y(#T@<W1R=&]L;W=E<BAL=')I;2@D<75E<GDI*3L-"B @ M(" @(" @:68@*"1I<VUA;FEP("8F('-U8G-T<B@D;6]D7W%U97)Y+" P+" V M*2 ]/2 G9&5L971E)RD-"B @(" @(" @(" @('L-"B @(" @(" @(" @(" @ M(" D<V5L96-T7W%U97)Y(#T@<W1R7W)E<&QA8V4H)V1E;&5T92<L(G-E;&5C M=" D;&]B7V9I96QD(BPD;6]D7W%U97)Y*3L-"B @(" @(" @(" @(" @("!I M9B H)'1H:7,M/F%U=&]?8V]M;6ET("8F($U$0CHZ:7-%<G)O<B@D=&AI<RT^ M7V1O475E<GDH)T)%1TE.)RDI*2![#0H@(" @(" @(" @(" @(" @(" @("!R M971U<FXH)'1H:7,M/G)A:7-E17)R;W(H341"7T524D]2*2D[#0H@(" @(" @ M(" @(" @(" @?0T*(" @(" @(" @(" @(" @("1R97-U;'0@/2 D=&AI<RT^ M7V1O475E<GDH)'-E;&5C=%]Q=65R>2D[#0H@(" @(" @(" @(" @(" @(&EF M("@A341".CII<T5R<F]R*"1R97-U;'0I*2 -"B @(" @(" @(" @(" @(" @ M(" @('L-"B @(" @(" @(" @(" @(" @(" @(" @(" D;VED<R ]($!P9U]F M971C:%]A;&PH)')E<W5L="D[#0H@(" @(" @(" @(" @(" @(" @(" @(" @ M9F]R96%C:"@D;VED<R!A<R D:6YD97@@/3X@)&1A=&$I>PT*(" @(" @(" @ M(" @(" @(" @(" @(" @(" @("!I9BAI<W-E="@D9&%T85LD;&]B7V9I96QD M72DI>PT*(" @(" @(" @(" @(" @(" @(" @(" @(" @(" M72DI>@(" @<&=?;&]? M=6YL:6YK*"1D871A6R1L;V)?9FEE;&1=*3L-"B @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @?0T*(" @(" @(" @(" @(" @(" @(" @(" @('T-"B @ M(" @(" @(" @(" @(" @(" @('UE;'-E>PT*(" @(" @(" @(" @(" @(" @ M(" @(" @("1T:&ES+3YF<F5E4F5S=6QT*"1R97-U;'0I.PT*(" @(" @(" @ M(" @(" @(" @(" @(" @(')E='5R;B@D<F5S=6QT*3L-"B @(" @(" @(" @ M(" @(" @(" @('T-"B @(" @(" @(" @(" @(" @:68H341".CII<T5R<F]R M*"1R97-U;'0R(#T@)'1H:7,M/E]D;U%U97)Y*"1Q=65R>2DI*7L-"B @(" @ M(" @(" @(" @(" @(" @("1T:&ES+3YF<F5E4F5S=6QT*"1R97-U;'0R*3L- M"B @(" @(" @(" @(" @(" @(" @(')E='5R;B@D<F5S=6QT,BD[#0H@(" @ M(" @(" @(" @(" @('T@#0H@(" @(" @(" @(" @(" @(&EF("@D=&AI<RT^ M875T;U]C;VUM:70@)B8@341".CII<T5R<F]R*"1R97-U;'0S(#T@)'1H:7,M M/E]D;U%U97)Y*"=%3D0G*2DI('L-"B @(" @(" @(" @(" @(" @(" @("1T M:&ES+3YF<F5E4F5S=6QT*"1R97-U;#(I.PT*(" @(" @(" @(" @(" @(" @ M(" @<F5T=7)N*"1R97-U;'0S*3L-"B @(" @(" @(" @(" @(" @?0T*(" @ M(" @(" @(" @?65L<V5[#0H@(" @(" @(" @(" @(" @<F5T=7)N*"1T:&ES M+3YR86ES945R<F]R*$U$0E]%4E)/4BDI.PT*(" @(" @(" @(" @?0T*(" @ ;(" @("!R971U<FXH341"7T]+*3L-"B @("!] ` end

« previous php.pear.dev (#17194) next »