Index: openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql	19 Aug 2002 19:55:40 -0000	1.1
+++ openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql	6 Oct 2002 23:43:39 -0000	1.2
@@ -1,9 +1,7 @@
 -- created by arjun@openforce.net 
 -- from a bug fix by  Deds Castillo
 
-drop function acs_event__recurrence_timespan_edit;
-
-create function acs_event__recurrence_timespan_edit (
+create or replace function acs_event__recurrence_timespan_edit (
        integer,
        timestamp,
        timestamp
@@ -27,15 +25,24 @@
           and timespans.timespan_id = acs_events.timespan_id
           and event_id=p_event_id;
 
+        -- RBM: Converted inneficient query to INNER JOINs (2002-10-06)
+	--
+        -- FOR v_timespan in
+        --    select *
+        --    from time_intervals
+        --    where interval_id in (select interval_id
+        --                          from timespans 
+        --                          where timespan_id in (select timespan_id
+        --                                                from acs_events 
+        --                                                where recurrence_id = (select recurrence_id 
+        --                                                                       from acs_events where event_id = p_event_id)))
+
         FOR v_timespan in
-            select *
-            from time_intervals
-            where interval_id in (select interval_id
-                                  from timespans 
-                                  where timespan_id in (select timespan_id
-                                                        from acs_events 
-                                                        where recurrence_id = (select recurrence_id 
-                                                                               from acs_events where event_id = p_event_id)))
+            SELECT ti.*
+              FROM time_intervals ti, timespans t, acs_events ae
+	     WHERE ti.interval_id = t.interval_id
+	       AND t.timespan_id = ae.timespan_id
+	       AND ae.event_id = p_event_id
         LOOP
                 PERFORM time_interval__edit(v_timespan.interval_id, 
                                             v_timespan.start_date + (p_start_date - v_one_start_date), 
