Moodle

lib/statslib SQL errors under Oracle

Details

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

Description

Under Oracle, SQL statements like "SELECT fields1, fields2" with no "FROM table" are invalid and produce a "FROM keyword not found where expected" error. This is most obvious when the cron task performs its stats collection. The solution is to select from the dummy 'DUAL' table in statements affected.

Attached is my workaround patch I'm using for the moment, which is probably only useful to locate the problematic statements until an official solution is implemented. Perhaps a function like the one below could be added to dmllib to get around this in a compatible manner?

function sql_null_from() {
global $CFG;
switch ($CFG->dbfamily) { case 'oracle': return 'FROM DUAL'; default: return ''; }
}

  1. MDL-13861.patch.txt
    21/Jun/08 8:58 AM
    27 kB
    Eloy Lafuente (stronk7)
  2. usq-stats-from-dual.patch
    10/Mar/08 4:36 PM
    6 kB
    Jonathon Fowler

Issue Links

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Wow Jonathon, well spotted! B-)

I'll try to fix this tomorrow (by implementing the function and using it where necessary!

Thanks for the report (grrr... that's because my dev oracle installation hasn't stats enabled... grrr) !

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Wow Jonathon, well spotted! B-) I'll try to fix this tomorrow (by implementing the function and using it where necessary! Thanks for the report (grrr... that's because my dev oracle installation hasn't stats enabled... grrr) ! Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Jonathon,

attached is one patch that should fix the problem under Oracle. While I was working on this I saw some more problems in the queries, so the patch is complexer than simply adding the "from dual".

Now it should be 100% cross-db. Going to perform some more tests this weekend and will commit it in 1-2 days.

Sorry by the delay... this was missing under a bunch of bugs. Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Jonathon, attached is one patch that should fix the problem under Oracle. While I was working on this I saw some more problems in the queries, so the patch is complexer than simply adding the "from dual". Now it should be 100% cross-db. Going to perform some more tests this weekend and will commit it in 1-2 days. Sorry by the delay... this was missing under a bunch of bugs. Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Patch applied against 19_STABLE, will be available in next weekly builds.

Notes:

  • Pending to merge to HEAD.
  • Pending to fix MSSQL ( MDL-15336 )

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Patch applied against 19_STABLE, will be available in next weekly builds. Notes:
  • Pending to merge to HEAD.
  • Pending to fix MSSQL ( MDL-15336 )
Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Changes applied to HEAD. Resolving this as fixed. Going to handle MDL-15336

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Changes applied to HEAD. Resolving this as fixed. Going to handle MDL-15336 Ciao
Hide
Tim Hunt added a comment -

Fix looks good to me, and cron still seems to work.

Show
Tim Hunt added a comment - Fix looks good to me, and cron still seems to work.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: