[postgis-users] Creating a Flow Diagram

Sufficool, Stanley ssufficool at rov.sbcounty.gov
Thu Jun 5 11:15:59 PDT 2008


OK, I'm trying to come up with a solid solution to all this since it
roughly applies to some things I'm doing with attached objects and
location tracking.

This rule is resulting in infinite recursion when there is no reason for
the rule to even execute. 

Am I understanding the rules system wrong or should this be a trigger
function?

-------------------

create or replace rule entity_update AS ON update TO entity 
WHERE NOT (st_AsText(OLD.the_geom) ~= st_AsText(NEW.the_geom)) -- Only
if geometry was modifed (I'm sure there is a more appropriate operator
here)
DO UPDATE entity 
	SET the_geom = st_translate(
		-- Center the child on parent geometry
		st_translate( 
			the_geom, 
			st_x(st_centroid(NEW.the_geom)) -
st_x(st_centroid(the_geom)),  
			st_y(st_centroid(NEW.the_geom)) -
st_y(st_centroid(the_geom)),
			st_z(st_centroid(NEW.the_geom)) -
st_z(st_centroid(the_geom))		
		),
		--Translate to relative position of parent 
		( st_xmax(NEW.the_geom) - st_xmin(NEW.the_geom) ) *
ratio_x,
		( st_ymax(NEW.the_geom) - st_ymin(NEW.the_geom) ) *
ratio_y,
		( st_zmax(NEW.the_geom) - st_zmin(NEW.the_geom) ) *
ratio_z
	)
	WHERE parent_entity_id = NEW.entity_id	--Update all children of
the modified parent record
;

-- NOW LETS touch the parent
update entity SET the_geom = st_translate(the_geom, 0, 0) where
entity_id = (SELECT MIN(entity_id) FROM entity)


ERROR:  infinite recursion detected in rules for relation "entity"

********** Error **********

ERROR: infinite recursion detected in rules for relation "entity"
SQL state: 42P17
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diagram2.sql
Type: application/octet-stream
Size: 2720 bytes
Desc: diagram2.sql
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080605/a707ab69/attachment.obj>


More information about the postgis-users mailing list