Issue Details (XML | Word | Printable)

Key: MDL-11270
Type: Sub-task Sub-task
Status: Open Open
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Eloy Lafuente (stronk7)
Votes: 3
Watchers: 4
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-14679

Analyse the impact and roadmap to move, under MSSQL, from ntext to nvarchar(max)

Created: 14/Sep/07 03:47 AM   Updated: 20/Jan/09 02:31 AM
Return to search
Component/s: Database SQL/XMLDB
Affects Version/s: 2.0
Fix Version/s: 2.0

Issue Links:
Dependency
 

Database: Microsoft SQL
Participants: Eloy Lafuente (stronk7), Jonathan Moore and Martin Dougiamas
Security Level: None
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
It seems that ntext is deprecated in latest MSSQL versions and the recommended way is to use nvarchar(max) instead.

Analyse how we can change that, their impact both in dml and ddl libraries.

Some initial references:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=421702&SiteID=1
http://msdn2.microsoft.com/en-US/library/ms189087.aspx

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Eloy Lafuente (stronk7) added a comment - 17/Sep/07 02:08 AM
Linking with another (closed) bug about the same issue. MDL-9845

Martin Dougiamas added a comment - 08/Sep/08 10:25 AM
Eloy, could you please look into this issue soon?

Jonathon Moore reported this error which seems to be related to this issue...

"The ntext data type cannot be selected as DISTINCT because it is not comparable."

From:

SELECT DISTINCT r.* FROM mdl_role r, mdl_role_assignments ra, mdl_role_allow_override rao WHERE ra.userid = 2 AND ra.contextid IN (1) AND rao.roleid = ra.roleid AND r.id = rao.allowoverride ORDER BY r.sortorder ASC

  • line 686 of lib/dmllib.php: call to debugging()
  • line 966 of lib/dmllib.php: call to get_recordset_sql()
  • line 4128 of lib/accesslib.php: call to get_records_sql()
  • line 65 of admin/roles/assign.php: call to get_overridable_roles()

Is there some quick-fix MS SQL config option that can make this work?


Eloy Lafuente (stronk7) added a comment - 08/Sep/08 11:04 PM
Hi,

if I'm not wrong, that exact problem was fixed some weeks ago (see MDL-16034) both in 19_STABLE and HEAD, so updating to latest 1.9.x weekly should solve it.

AFAIK there isn't any switch in MS-SQL to change that behaviour.

TEXT and IMAGE (formerly CLOB and BLOB) columns have serious limitations both in DISTINCT and UNION queries. And that not only affects MSSQL but also Oracle (plus causing big speed problems under MySQL and PostgreSQL).

So we should rewrite those queries always, avoiding using them in DISTINCT and UNION clauses (see again MDL-16034 for a general-purpose way to rewrite them, avoiding TEXT columns in those calculations).

We can consider switching to nvarchar(max) under MSQL in the future, yes. But that won't solve the underlying problem, so better to continue rewriting queries for now. IMO.

Ciao


Jonathan Moore added a comment - 10/Sep/08 03:24 AM
Eloy are there any text searches we might be able to perform on the code base to help find the spots where this happens? I would be happy to have one our our technical staff run this down and get them documented in the issues tracker that helps.

I have Nick loading up the latest weekly to see if it resolves the error messages we have seen so far.

Based on what you are saying, I take it that its not a good idea for us to manually change the data types to nvarchar on this instance of Moodle as a form of work around?

Thanks for the follow up on this. We will report back shortly.