MDL-67394 dml: improve thrown exception when Oracle can't parse query.

This commit is contained in:
Paul Holden 2020-07-21 23:49:03 +01:00
parent 07238ca511
commit 42fcf7d5da
2 changed files with 5 additions and 2 deletions

View file

@ -221,6 +221,7 @@ $string['ddlxmlfileerror'] = 'XML database file errors found';
$string['destinationcmnotexit'] = 'The destination course module does not exist'; $string['destinationcmnotexit'] = 'The destination course module does not exist';
$string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective or outdated, can not continue, sorry.'; $string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective or outdated, can not continue, sorry.';
$string['dmlexceptiononinstall'] = '<p>A database error has occurred [{$a->errorcode}].<br />{$a->debuginfo}</p>'; $string['dmlexceptiononinstall'] = '<p>A database error has occurred [{$a->errorcode}].<br />{$a->debuginfo}</p>';
$string['dmlparseexception'] = 'Error parsing SQL query';
$string['dmlreadexception'] = 'Error reading from database'; $string['dmlreadexception'] = 'Error reading from database';
$string['dmltransactionexception'] = 'Database transaction error'; $string['dmltransactionexception'] = 'Database transaction error';
$string['dmlwriteexception'] = 'Error writing to database'; $string['dmlwriteexception'] = 'Error writing to database';

View file

@ -345,14 +345,16 @@ class oci_native_moodle_database extends moodle_database {
/** /**
* Prepare the statement for execution * Prepare the statement for execution
* @throws dml_connection_exception *
* @param string $sql * @param string $sql
* @return resource * @return resource
*
* @throws dml_exception
*/ */
protected function parse_query($sql) { protected function parse_query($sql) {
$stmt = oci_parse($this->oci, $sql); $stmt = oci_parse($this->oci, $sql);
if ($stmt == false) { if ($stmt == false) {
throw new dml_connection_exception('Can not parse sql query'); //TODO: maybe add better info throw new dml_exception('dmlparseexception', null, $this->get_last_error());
} }
return $stmt; return $stmt;
} }