Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.8.0d3-5.8.0d4.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.8.0d3-5.8.0d4.sql,v
diff -u -r1.4 -r1.4.2.1
--- openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.8.0d3-5.8.0d4.sql	29 May 2013 09:41:47 -0000	1.4
+++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.8.0d3-5.8.0d4.sql	22 Oct 2018 10:41:45 -0000	1.4.2.1
@@ -13,8 +13,9 @@
     ret_val = 0;
 
     user_pg_version := string_to_array(trim(p__version),'.')::int[];
-    select string_to_array(setting, '.')::int[] into pg_version from pg_settings where name = 'server_version';
 
+    --select string_to_array(setting, '.')::int[] into pg_version from pg_settings where name = 'server_version';
+    select string_to_array(setting::int/10000 || '.' || (setting::int%10000)/100 || '.' || (setting::int%100), '.')::int[] into pg_version from pg_settings where name = 'server_version_num';
 
     for index in array_length(user_pg_version, 1) + 1..array_length(pg_version, 1) loop
         user_pg_version[index] := 0;