Skip to content

Commit

Permalink
MDL-17020 dml: native pgsql driver - more resource freeing
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 27, 2008
1 parent f05c20f commit e4f9c14
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/dml/pgsql_native_moodle_database.php
Expand Up @@ -365,6 +365,8 @@ public function get_columns($table, $usecache=true) {
$this->columns[$table][$info->name] = new database_column_info($info);
}

pg_free_result($result);

return $this->columns[$table];
}

Expand Down Expand Up @@ -437,7 +439,7 @@ public function change_database_structure($sql) {
$this->report_error($sql);
return false;
}
// no need to free result, we do not expect any here
pg_free_result($result);
return true;
}

Expand Down Expand Up @@ -465,7 +467,7 @@ public function execute($sql, array $params=null) {
return false;

}

pg_free_result($result);
return true;
}

Expand Down Expand Up @@ -652,8 +654,8 @@ public function insert_record_raw($table, $params, $returnid=true, $bulk=false,
if ($returning !== "") {
$row = pg_fetch_assoc($result);
$params['id'] = reset($row);
pg_free_result($result);
}
pg_free_result($result);

if (!$returnid) {
return true;
Expand Down Expand Up @@ -726,7 +728,10 @@ public function insert_record($table, $dataobject, $returnid=true, $bulk=false)
$this->writes++;
$value = pg_escape_bytea($this->pgsql, $value);
$sql = "UPDATE {$this->prefix}$table SET $key = '$value'::bytea WHERE id = $id";
pg_query($this->pgsql, $sql);
$result = pg_query($this->pgsql, $sql);
if ($result !== false) {
pg_free_result($result);
}
}

return ($returnid ? $id : true);
Expand Down Expand Up @@ -803,6 +808,7 @@ public function update_record_raw($table, $params, $bulk=false) {
return false;
}

pg_free_result($result);
return true;
}

Expand Down Expand Up @@ -882,6 +888,7 @@ public function set_field_select($table, $newfield, $newvalue, $select, array $p
$this->report_error($sql, $params);
return false;
}
pg_free_result($result);

return true;
}
Expand Down Expand Up @@ -910,6 +917,7 @@ public function delete_records_select($table, $select, array $params=null) {
$this->report_error($sql, $params);
return false;
}
pg_free_result($result);

return true;
}
Expand Down

0 comments on commit e4f9c14

Please sign in to comment.