Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-4.6.3-4.6.4.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-4.6.3-4.6.4.sql,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-4.6.3-4.6.4.sql	6 Jun 2003 08:41:27 -0000	1.1.2.1
+++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-4.6.3-4.6.4.sql	16 Jun 2003 16:19:35 -0000	1.1.2.2
@@ -59,3 +59,59 @@
   and m.rel_id = mr.rel_id
   and m.container_id = m.group_id;
 
+-- Fixing a really lame = null bug in this proc that would cause default values
+-- of new parameters to not be propagated to package instances
+create or replace function apm__register_parameter (integer,varchar,varchar,varchar,varchar,varchar,varchar,integer,integer)
+returns integer as '
+declare
+  register_parameter__parameter_id           alias for $1;  -- default null  
+  register_parameter__package_key            alias for $2;  
+  register_parameter__parameter_name         alias for $3;  
+  register_parameter__description            alias for $4;  -- default null  
+  register_parameter__datatype               alias for $5;  -- default ''string''  
+  register_parameter__default_value          alias for $6;  -- default null  
+  register_parameter__section_name           alias for $7;  -- default null 
+  register_parameter__min_n_values           alias for $8;  -- default 1
+  register_parameter__max_n_values           alias for $9;  -- default 1
+
+  v_parameter_id         apm_parameters.parameter_id%TYPE;
+  cur_val                record;
+begin
+    -- Create the new parameter.    
+    v_parameter_id := acs_object__new(
+       register_parameter__parameter_id,
+       ''apm_parameter'',
+       now(),
+       null,
+       null,
+       null
+    );
+    
+    insert into apm_parameters 
+    (parameter_id, parameter_name, description, package_key, datatype, 
+    default_value, section_name, min_n_values, max_n_values)
+    values
+    (v_parameter_id, register_parameter__parameter_name, 
+     register_parameter__description, register_parameter__package_key, 
+     register_parameter__datatype, register_parameter__default_value, 
+     register_parameter__section_name, register_parameter__min_n_values, 
+     register_parameter__max_n_values);
+
+    -- Propagate parameter to new instances.	
+    for cur_val in select ap.package_id, p.parameter_id, p.default_value 
+       from apm_parameters p left outer join apm_parameter_values v 
+             using (parameter_id), apm_packages ap
+      where p.package_key = ap.package_key
+        and v.attr_value is null
+        and p.package_key = register_parameter__package_key
+      loop
+      	PERFORM apm__set_value(
+	    cur_val.parameter_id, 
+	    cur_val.package_id,
+	    cur_val.default_value
+	    ); 	
+      end loop;	
+	
+    return v_parameter_id;
+   
+end;' language 'plpgsql';
