Permalink
Browse files

make classtype table update work when special schemas are used

  • Loading branch information...
1 parent b544a8c commit cbbcc2618fe6bb79a8d7ddfb84c806d90631ff33 @lonvia lonvia committed Nov 23, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 sql/functions.sql
View
@@ -1245,7 +1245,7 @@ BEGIN
-- Note: won't work on initial import because the classtype tables
-- do not yet exist. It won't hurt either.
classtable := 'place_classtype_' || NEW.class || '_' || NEW.type;
- SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable INTO result;
+ SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO result;
IF result THEN
EXECUTE 'INSERT INTO ' || classtable::regclass || ' (place_id, centroid) VALUES ($1,$2)'
USING NEW.place_id, ST_Centroid(NEW.geometry);
@@ -1987,7 +1987,7 @@ BEGIN
-- remove from tables for special search
classtable := 'place_classtype_' || OLD.class || '_' || OLD.type;
- SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable INTO b;
+ SELECT count(*)>0 FROM pg_tables WHERE tablename = classtable and schemaname = current_schema() INTO b;
IF b THEN
EXECUTE 'DELETE FROM ' || classtable::regclass || ' WHERE place_id = $1' USING OLD.place_id;
END IF;

0 comments on commit cbbcc26

Please sign in to comment.