Ticket #5037: functions.sql.patch

File functions.sql.patch, 1.1 KB (added by pedro', 6 years ago)
  • functions.sql

    old new BEGIN 
    12411241   -- Note: won't work on initial import because the classtype tables
    12421242   -- do not yet exist. It won't hurt either.
    12431243  classtable := 'place_classtype_' || NEW.class || '_' || NEW.type;
    1244   SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable INTO result;
     1244  SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO result;
    12451245  IF result THEN
    12461246    EXECUTE 'INSERT INTO ' || classtable::regclass || ' (place_id, centroid) VALUES ($1,$2)'
    12471247    USING NEW.place_id, ST_Centroid(NEW.geometry);
    BEGIN 
    19831983
    19841984  -- remove from tables for special search
    19851985  classtable := 'place_classtype_' || OLD.class || '_' || OLD.type;
    1986   SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable INTO b;
     1986  SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO b;
    19871987  IF b THEN
    19881988    EXECUTE 'DELETE FROM ' || classtable::regclass || ' WHERE place_id = $1' USING OLD.place_id;
    19891989  END IF;