[postgis-users] Delete locks temp table

Paulo Pires paulopires16 at gmail.com
Wed Jun 6 03:33:51 PDT 2018


Already did that but memory grows and grows... pids...


Paulo Pires

------------------------------
phone  964592113
e-mail  paulopires16 at gmail.com
crypt   myPGP public key for encryption emails
<http://kerckhoffs.surfnet.nl/pks/lookup?op=get&search=0x878711213981EEF6>
links    facebook <http://facebook.com/paulopires16> · twitter
<http://twitter.com/#!/paulopires16> · linkedin
<http://www.linkedin.com/pub/paulo-pires/36/4a7/607> · netlog
<http://netlog.com/paulopires16> · javase
<http://download.oracle.com/javase/6/docs/api/> · oracle
<http://www.oracle.com/us/syndication/feeds/index.html>
------------------------------

Aviso Legal:
Esta mensagem de Paulo Pires é destinada exclusivamente ao destinatário.
Pode conter informação confidencial ou legalmente protegida. A incorrecta
transmissão desta mensagem não significa a perda de confidencialidade. Se
esta mensagem for recebida por engano, por favor envie-a de volta para o
remetente e apague-a do seu sistema de imediato. É proibido a qualquer
pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte
desta mensagem.

Disclaimer:
This message from Paulo Pires is destined exclusively to the intended
receiver. It may contain confidential or legally protected information. The
incorrect transmission of this message does not mean the loss of its
confidentiality. If this message is received by mistake, please send it
back to the sender and delete it from your system immediately. It is
forbidden to any person who is not the intended receiver to use, distribute
or copy any part of this message.

2018-06-06 11:25 GMT+01:00 Darafei "Komяpa" Praliaskouski <me at komzpa.net>:

> Hello,
>
> Simplest is to move DROP TABLE from start to end of functions.
>
> Please have a look at this gist changes: https://gist.github.com/Komzpa/
> 38b66ee31b14542670529e5c8614f07c/revisions
>
> ср, 6 июн. 2018 г. в 13:07, Paulo Pires <paulopires16 at gmail.com>:
>
>> Thanks  Darafei,
>>
>> See the whole process. Do you mean make just one function?
>>
>>             CREATE OR REPLACE FUNCTION is_internal(polygon geometry, p2
>> geometry, p3 geometry)
>>             RETURNS boolean as
>>             $$
>>                 BEGIN
>>                     return st_contains(polygon, st_makeline(p2, p3));
>>                 END
>>             $$ language plpgsql;
>>
>>
>>             CREATE OR REPLACE FUNCTION angle(p1 geometry, p2 geometry, p3
>> geometry)
>>             RETURNS float AS
>>             $$
>>                 DECLARE
>>                     p12 float;
>>                     p23 float;
>>                     p13 float;
>>                 BEGIN
>>                 select st_distance(p1, p2) into p12;
>>                     select st_distance(p1, p3) into p13;
>>                     select st_distance(p2, p3) into p23;
>>                     return acos(  (p12^2 + p13^2 - p23^2) / (2*p12*p13)
>> );
>>                 END
>>             $$ language plpgsql;
>>
>>
>>             CREATE OR REPLACE FUNCTION internal_angle(polygon geometry,
>> p1 geometry, p2 geometry, p3 geometry)
>>             RETURNS float as
>>             $$
>>                 DECLARE
>>                     ang float;
>>                     is_intern boolean;
>>                 BEGIN
>>                     select temp.angle(p1, p2, p3) into ang;
>>                     select temp.is_internal(polygon, p2, p3) into
>> is_intern;
>>                     return ang;
>>                 END
>>             $$ language plpgsql;
>>
>>
>>             CREATE OR REPLACE FUNCTION corner_triplets(geom geometry)
>>             RETURNS table(corner_number integer, p1 geometry, p2
>> geometry, p3 geometry) AS
>>             $$
>>                 DECLARE
>>                     max_corner_number integer;
>>                 BEGIN
>>                     DROP TABLE IF EXISTS corners;
>>                     create temp table corners on commit drop as select
>> path[2] as corner_number, t1.geom as point from (select
>> (st_dumppoints($1)).*) as t1 where path[1] = 1;
>>                     select max(corners.corner_number) into
>> max_corner_number from corners;
>>                     insert into corners (corner_number, point) select 0,
>> point from corners where corners.corner_number = max_corner_number - 1;
>>
>>                 DROP TABLE IF EXISTS triplets;
>>                     create temp table triplets on commit drop as select
>> t1.corner_number, t1.point as p1, t2.point as p2,  t3.point as p3 from
>> corners as t1, corners as t2, corners as t3 where t1.corner_number =
>> t2.corner_number + 1 and t1.corner_number = t3.corner_number - 1;
>>                     return QUERY TABLE triplets;
>>                 END;
>>             $$
>>             LANGUAGE plpgsql;
>>
>>
>>             CREATE OR REPLACE FUNCTION internal_angles(geom geometry)
>>             RETURNS table(corner geometry, angle float)
>>             AS $$
>>                 BEGIN
>>                     DROP TABLE IF EXISTS internal_angs;
>>                     create temp table internal_angs on commit drop as
>> select p1, internal_angle(geom, p1, p2, p3) from (select (c).* from (select
>> corner_triplets(geom) as c) as t1) as t2;
>>                     return QUERY TABLE internal_angs;
>>                 END;
>>             $$
>>             LANGUAGE plpgsql;
>>
>>             DROP TABLE IF EXISTS allradians;
>>             select (c).* into allradians from (select
>> internal_angles(geom) as c from mytable) as t;
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180606/c89f8dd6/attachment.html>


More information about the postgis-users mailing list