Moodle

role_names->text causing problems under Oracle

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9
  • Component/s: Roles / Access
  • Labels:
    None
  • Database:
    Oracle
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Was testing a bit Moodle 1.9 under Oracle, when I got this error:

ORA-00932: inconsistent datatypes: expected CLOB got CHAR

SELECT r.id, COALESCE(rn.text, r.name) AS name FROM m_role r JOIN ( SELECT DISTINCT allowassign as allowedrole FROM m_role_allow_assign raa WHERE raa.roleid IN (3,1) ) ar ON r.id=ar.allowedrole JOIN m_role_capabilities rc ON (r.id = rc.roleid AND rc.capability = 'moodle/course:view' AND rc.capability != 'moodle/site:doanything') LEFT OUTER JOIN m_role_names rn ON (rn.roleid = r.id AND rn.contextid = 23) ORDER BY sortorder ASC

It seems that the role_names->text field is of type TEXT (CLOB) and that prevents it to be used within COALESCE and other functions.

If I'm not wrong that table, role_names, is exclusively used to name roles in a different way per context. If that is the only usage I would recommend to:

1) create one new role_names->name char(255) not null field.
2) copy current role_names->text contents to role_names->name
3) drop role_names->text
4) Change usages from the old field to the new one.

That way the field will be better and his behaviour cross-db.

Ciao

P.S.: Raising this to critical... to alarm about it (prevents Oracle usage completely)

Issue Links

Activity

Hide
Tim Hunt added a comment -

The only possible reason I can think of for allowing TEXT is what about a course available in 100 languages, were someone wants to use the multilang filter on the role name (I don't even know if you can use the multilang filter there.)

Of course, this argument would apply even more to role->name.

Show
Tim Hunt added a comment - The only possible reason I can think of for allowing TEXT is what about a course available in 100 languages, were someone wants to use the multilang filter on the role name (I don't even know if you can use the multilang filter there.) Of course, this argument would apply even more to role->name.
Hide
Eloy Lafuente (stronk7) added a comment -

Good point, Tim!

Anyway... I think that, if that's the case, we really need to modify more places to support multilang with that info. It seems, after a quick review, that some functions are able to format_string() that info, while others aren't.

Uhm... with 255cc, 2-3 langs could be easily supported and we'll get true cross-db. Else we'll need some conditional queries in accesslib to avoid the problem (or complexer queries = slower).

So, +1 to go down to 255cc here.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Good point, Tim! Anyway... I think that, if that's the case, we really need to modify more places to support multilang with that info. It seems, after a quick review, that some functions are able to format_string() that info, while others aren't. Uhm... with 255cc, 2-3 langs could be easily supported and we'll get true cross-db. Else we'll need some conditional queries in accesslib to avoid the problem (or complexer queries = slower). So, +1 to go down to 255cc here. Ciao
Hide
Martin Dougiamas added a comment -

Wow, Oracle sucks. There is no reason they have to be the same type - it's just looking for the first non-null item in the list. Sigh.

OK, I'm working on this now. I think there are some other Oracle showstoppers actually. I'll link them to this bug when I find them.

Show
Martin Dougiamas added a comment - Wow, Oracle sucks. There is no reason they have to be the same type - it's just looking for the first non-null item in the list. Sigh. OK, I'm working on this now. I think there are some other Oracle showstoppers actually. I'll link them to this bug when I find them.
Hide
Martin Dougiamas added a comment -

This is fixed now. I've tested quite well so I'm pretty confident I found all the places it was being used.

Fixed a problem on the user profiles along the way (it wasn't using the aliases but it is now)

Show
Martin Dougiamas added a comment - This is fixed now. I've tested quite well so I'm pretty confident I found all the places it was being used. Fixed a problem on the user profiles along the way (it wasn't using the aliases but it is now)

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: