--- webform.module460	2005-06-14 22:11:59.000000000 +0200
+++ webform.module	2005-06-21 01:29:21.000000000 +0200
@@ -1076,16 +1076,11 @@
     if (is_array($value)) {
       $value = serialize($value);
     }
- 
-    $sqlstring[] = " (%d, %d, '%s', '%s') ";
-    $values[] = $node->nid;
-    $values[] = $sid;
-    $values[] = $key;
-    $values[] = $value;
-  }
 
   db_query("INSERT INTO {webform_submitted_data} (nid, sid, name, data) ".
-           "VALUES ".implode(', ', $sqlstring), $values);
+             "VALUES (%d, %d, '%s', '%s')", $node->nid, $sid, $key, $value);
+    }
+
 }
 
 function _webform_role_node_delete($nid) {
@@ -1170,12 +1165,11 @@
 
 	$lazy_update_output = '';
 	$field_list = '';
-  $table_altered = false;
+	$table_altered = false;
 
-  // {webform}
 	$required_fields = array('nid' => false,'confirmation' => false,'email' => false,'email_from' => false,'email_subject' => false);
-  $result = db_query("SHOW FIELDS FROM {webform}");
-
+ // $result = db_query("SHOW FIELDS FROM {webform}");
+$result = db_query("SELECT attname as \"Field\" FROM pg_class a INNER JOIN pg_attribute b ON a.relfilenode=b.attrelid WHERE a.relname='webform' AND NOT b.attisdropped AND b.attnum>0");
 	// Mark fields that exist in table as true
 	while ($record = db_fetch_object($result)){
 		$required_fields[$record->Field] = true;
@@ -1185,8 +1179,8 @@
 		if(!$required_field){
 			// Field does not exist so we need to create it.
 			switch($field_name){
-				case 'email_subject':		// Contains the component name of the source field for the email subject
-				case 'email_from':			// Contains the component name of the source field for the email from address.
+				case 'email_subject':	// Contains the component name of the source field for the email subject
+				case 'email_from':	// Contains the component name of the source field for the email from address.
 					db_query("ALTER TABLE {webform} ADD COLUMN %s varchar(255)",$field_name);
 					$table_altered = true;
           $field_list .= " $field_name ";
