Moodle

Moodle Features Demo course does not restore cleanly to Oracle

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9.5
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Database:
    Oracle
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

The Moodle features demo course does not restore cleanly to Oracle.

The main problem has to do with explicit comparisons between CLOBs and text that are performed to avoid duplicate records. Oracle does not support something as simple as

SELECT id FROM table WHERE clobcolumn = 'sometext';

Upon this, it barfs with "ORA-00932: inconsistent datatypes: expected - got CLOB"

Instead, we have to do

SELECT id FROM table WHERE clobcolumn LIKE 'sometext';

with the added inconsistency that under MySQL LIKE is case-insensitive. It is case-sensitive everywhere else.

There are additional problems with hotpot and quoting.

Issue Links

Activity

Hide
Martín Langhoff added a comment -

Eloy, need your help & review here

I have a patch for the LIKE issue that you can see at http://git.catalyst.net.nz/gw?p=moodle-r2.git;a=commitdiff;h=91ac0f5e963c792857b230b54c285a79012704a6 - I think it's pretty safe and I'll commit soon.

The hotpot problem is quite tricky, and it's about quoting rules. If I patch hotpot like this

— a/mod/hotpot/restorelib.php
+++ b/mod/hotpot/restorelib.php
@@ -395,6 +395,7 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys,
}
if (empty($record->id)) { // add the $record (and get new id) + error_log(var_export($record,1)); $record->id = insert_record($table, $record); }
// check $record was added (or found)

I get the following in the error log (all logging redirected there)

stdClass::__set_state(array(
'modtype' => 'hotpot',
'course' => 332,
'name' => 'Newton\\'
's 2nd and 3rd Laws Pretest',
'reference' => 'hotpot/2ndand3rdlawpreptest.htm',
'summary' => 'Quiz',
'timeopen' => '0 ',
'timeclose' => '0 ',
'attempts' => '0 ',
'grademethod' => '1',
'review' => '1',
'grade' => '100',
'timecreated' => '1159128512',
'timemodified' => '1159128512',
'location' => '0 ',
'navigation' => '2',
'outputformat' => '1',
'shownextquiz' => '0 ',
'forceplugins' => '0 ',
'password' => '
'
' ',
'subnet' => '
'
' ',
'clickreporting' => '0 ',
'studentfeedback' => '0 ',
'studentfeedbackurl' => '
'
' ',
'old_id' => '33',
)),

And then Oracle barfs as follows. If you look at those 'empty' fields, it seems like we are getting a doubled-up-quoting in a set of single quotes. I suspect that perhaps the XML in the backup file is bad, and that the handling we have of such strange data is even worse...

ORA-00917: missing comma<br /><br />INSERT INTO m_hotpot ( ID, COURSE, NAME, SUMMARY, TIMEOPEN, TIMECLOSE, LOCATION, REFERENCE, OUTPUTFORMAT, NAVIGATION, STUDENTFEEDBACK, STUDENTFEEDBACKURL, FORCEPLUGINS, SHOWNEXTQUIZ, REVIEW, GRADE, GRADEMETHOD, ATTEMPTS, PASSWORD, SUBNET, CLICKREPORTING, TIMECREATED, TIMEMODIFIED ) VALUES ( 26, 332, 'Newton''s 2nd and 3rd Laws Pretest', 'Quiz', 0, 0, 0, 'hotpot/2ndand3rdlawpreptest.htm', 1, 2, 0, '' ' ', 0, 0, 1, 100, 1, 0, '' ' ', '' ' ', 0, 1159128512, 1159128512 )<ul style="text-align: left"><li>line 1600 of lib/dmllib.php: call to debugging()</li><li>line 399 of mod/hotpot/restorelib.php: call to insert_record()</li><li>line 272 of mod/hotpot/restorelib.php: call to hotpot_restore_record()</li><li>line 117 of mod/hotpot/restorelib.php: call to hotpot_restore_records()</li><li>line 3519 of backup/restorelib.php: call to hotpot_restore_mods()</li><li>line 7151 of backup/restorelib.php: call to restore_create_modules()</li><li>line 47 of backup/restore_execute.html: call t in /home/martin/public_html/moodle-r2.ora/lib/weblib.php on line 6846, referer: http://localhost/~martin/moodle-r2.ora/backup/restore.php

If I tidy up the "empty" fields to be just ' ', SQLPlus likes it a lot more...

Show
Martín Langhoff added a comment - Eloy, need your help & review here I have a patch for the LIKE issue that you can see at http://git.catalyst.net.nz/gw?p=moodle-r2.git;a=commitdiff;h=91ac0f5e963c792857b230b54c285a79012704a6 - I think it's pretty safe and I'll commit soon. The hotpot problem is quite tricky, and it's about quoting rules. If I patch hotpot like this — a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -395,6 +395,7 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, } if (empty($record->id)) { // add the $record (and get new id) + error_log(var_export($record,1)); $record->id = insert_record($table, $record); } // check $record was added (or found) I get the following in the error log (all logging redirected there) stdClass::__set_state(array( 'modtype' => 'hotpot', 'course' => 332, 'name' => 'Newton\\'
's 2nd and 3rd Laws Pretest', 'reference' => 'hotpot/2ndand3rdlawpreptest.htm', 'summary' => 'Quiz', 'timeopen' => '0 ', 'timeclose' => '0 ', 'attempts' => '0 ', 'grademethod' => '1', 'review' => '1', 'grade' => '100', 'timecreated' => '1159128512', 'timemodified' => '1159128512', 'location' => '0 ', 'navigation' => '2', 'outputformat' => '1', 'shownextquiz' => '0 ', 'forceplugins' => '0 ', 'password' => '
'
' ', 'subnet' => '
'
' ', 'clickreporting' => '0 ', 'studentfeedback' => '0 ', 'studentfeedbackurl' => '
'
' ', 'old_id' => '33', )), And then Oracle barfs as follows. If you look at those 'empty' fields, it seems like we are getting a doubled-up-quoting in a set of single quotes. I suspect that perhaps the XML in the backup file is bad, and that the handling we have of such strange data is even worse... ORA-00917: missing comma<br /><br />INSERT INTO m_hotpot ( ID, COURSE, NAME, SUMMARY, TIMEOPEN, TIMECLOSE, LOCATION, REFERENCE, OUTPUTFORMAT, NAVIGATION, STUDENTFEEDBACK, STUDENTFEEDBACKURL, FORCEPLUGINS, SHOWNEXTQUIZ, REVIEW, GRADE, GRADEMETHOD, ATTEMPTS, PASSWORD, SUBNET, CLICKREPORTING, TIMECREATED, TIMEMODIFIED ) VALUES ( 26, 332, 'Newton''s 2nd and 3rd Laws Pretest', 'Quiz', 0, 0, 0, 'hotpot/2ndand3rdlawpreptest.htm', 1, 2, 0, '' ' ', 0, 0, 1, 100, 1, 0, '' ' ', '' ' ', 0, 1159128512, 1159128512 )<ul style="text-align: left"><li>line 1600 of lib/dmllib.php: call to debugging()</li><li>line 399 of mod/hotpot/restorelib.php: call to insert_record()</li><li>line 272 of mod/hotpot/restorelib.php: call to hotpot_restore_record()</li><li>line 117 of mod/hotpot/restorelib.php: call to hotpot_restore_records()</li><li>line 3519 of backup/restorelib.php: call to hotpot_restore_mods()</li><li>line 7151 of backup/restorelib.php: call to restore_create_modules()</li><li>line 47 of backup/restore_execute.html: call t in /home/martin/public_html/moodle-r2.ora/lib/weblib.php on line 6846, referer: http://localhost/~martin/moodle-r2.ora/backup/restore.php If I tidy up the "empty" fields to be just ' ', SQLPlus likes it a lot more...
Hide
Martin Dougiamas added a comment -

Can we delay this?

Show
Martin Dougiamas added a comment - Can we delay this?
Hide
Vivienne Counter added a comment -

Hi
We are generally very inetersted in getting the Oracle errors cleaned up, but hotpot is not a module that we are promoting, so it is not a priority for us at this time. I do know we have a number of lecturers who like to use it though.

Show
Vivienne Counter added a comment - Hi We are generally very inetersted in getting the Oracle errors cleaned up, but hotpot is not a module that we are promoting, so it is not a priority for us at this time. I do know we have a number of lecturers who like to use it though.
Hide
Eloy Lafuente (stronk7) added a comment -

Uhm... the problem with scales was fixed long ago. Tomorrow I'll look to the events problem (it should be simply a matter of changing current get_records() changed to get_records_sql() and apply sql_compare_text() to the description field.

Show
Eloy Lafuente (stronk7) added a comment - Uhm... the problem with scales was fixed long ago. Tomorrow I'll look to the events problem (it should be simply a matter of changing current get_records() changed to get_records_sql() and apply sql_compare_text() to the description field.
Hide
Eloy Lafuente (stronk7) added a comment -

Fixed in 19_STABLE and HEAD. Now events restore is using sql_compare_text() to compare TEXT columns. Resolving, ciao

Show
Eloy Lafuente (stronk7) added a comment - Fixed in 19_STABLE and HEAD. Now events restore is using sql_compare_text() to compare TEXT columns. Resolving, ciao
Hide
Petr Škoda (skodak) added a comment -

thanks

Show
Petr Škoda (skodak) added a comment - thanks

Dates

  • Created:
    Updated:
    Resolved: