Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.1d3-5.9.1d4.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.1d3-5.9.1d4.sql,v
diff -u -r1.1.2.5 -r1.1.2.6
--- openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.1d3-5.9.1d4.sql	5 Aug 2016 14:31:38 -0000	1.1.2.5
+++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.1d3-5.9.1d4.sql	9 Sep 2016 07:32:25 -0000	1.1.2.6
@@ -1,30 +1,20 @@
-create or replace function inline_0 ()
+CREATE or REPLACE FUNCTION inline_0 ()
 returns integer as $$
 DECLARE
    v_dummy integer;
 BEGIN
-   select setting from pg_settings where name='server_version_num' and setting::int >= 90200 into v_dummy;
-   IF found THEN
+    SELECT 1 FROM pg_views WHERE viewname = 'anon_func_seq' INTO v_dummy;
+    IF found THEN
 
-        select 1 from pg_views where viewname = 'anon_func_seq' into v_dummy;
-	IF found THEN
-      	   drop view IF EXISTS anon_func_seq;
-   	   ALTER SEQUENCE IF EXISTS t_anon_func_seq RENAME TO anon_func_seq;
-	END IF;
+        DROP VIEW IF EXISTS anon_func_seq;
+        IF EXISTS (SELECT 0 FROM pg_class WHERE relname = 't_anon_func_seq' ) THEN
+            ALTER SEQUENCE t_anon_func_seq RENAME TO anon_func_seq;
+        END IF;
 
-   ELSE
-	-- verison earlier than 9.2, no "IF EXISTS" for ALTER SEQUENCE
-        select 1 from pg_views where viewname = 'anon_func_seq' into v_dummy;
-	IF found THEN
-	   drop view anon_func_seq;
-      	   ALTER SEQUENCE t_anon_func_seq RENAME TO anon_func_seq;
-	END IF;
-
    END IF;
    return 1;
 END;
-$$ language 'plpgsql';
+$$ language plpgsql;
 
 select inline_0();
 drop function inline_0();
-
