]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17491 oci native driver: prevent get_columns() to execute huge queries
authorstronk7 <stronk7>
Mon, 28 Sep 2009 10:27:24 +0000 (10:27 +0000)
committerstronk7 <stronk7>
Mon, 28 Sep 2009 10:27:24 +0000 (10:27 +0000)
and fix return binding to proper SQLT_INT. Truncation was happening with LONG!

lib/dml/oci_native_moodle_database.php

index 2aa6ab103aa62b155661fb71bbe62114e139346d..289600562cbbfc06891f5e67604a295e2548f6ed 100644 (file)
@@ -369,6 +369,10 @@ class oci_native_moodle_database extends moodle_database {
             return $this->columns[$table];
         }
 
+        if (!$table) { // table not specified, return empty array directly
+            return array();
+        }
+
         $this->columns[$table] = array();
 
         $tablename = strtoupper($this->prefix.$table);
@@ -1066,7 +1070,7 @@ class oci_native_moodle_database extends moodle_database {
         $stmt = $this->parse_query($sql);
         $descriptors = $this->bind_params($stmt, $params, $table);
         if ($returning) {
-            oci_bind_by_name($stmt, ":oracle_id", $id, -1, SQLT_LNG);
+            oci_bind_by_name($stmt, ":oracle_id", $id, -1, SQLT_INT);
         }
         $result = oci_execute($stmt, $this->commit_status);
         $this->free_descriptors($descriptors);