DB layer 2.0 problems

Revision as of 07:16, 6 May 2009 by Petr Škoda (škoďák) (talk | contribs) (ADOdb Insert_ID() function under MSSQL, using placeholders doesn't work)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.

Moodle 2.0


Every section on this page will show important problems present in the adoption of the new dmllib 2.0. Each section will define the problem, its impact and, when available, its solution. Every section will include one line containing its status ('Open', 'Decided, 'Work in progress', 'Finished', 'Tested' and 'Closed').

Of course, feel free to use the Bug Tracker to follow the daily evolution of each one of these problems by adding one link inside each section pointing to the proper bug.

Do we still need record cache

(Status: Open - Severity: Not Critical - Bug: not defined)

No we do not, but people must stop using get_record() in large loops (like the case of latest conditional changes in gradebook). Petr Škoda (škoďák)

Unknown parameter types in query parameters

(Status: Open - Severity: Not Critical - Bug: not defined)

We can find out the correct type of each param for inserts and updates, but in case of other queries it might be a problem :-( we could use optional type hints in parameter names like :numberI, :numberD, :nameS where IDS means int, double, string (like in mysqli driver)

Wouldn't some params->setInt(), setString(), setNull() do the trick? Once more the possible substitution of the plain array of values to one array of objects seems to appear in the discussion... Eloy Lafuente (stronk7) 19:35, 6 May 2008 (CDT)

casting to (int) in insert_record()

(Status: Open - Severity: Not Critical - Bug: not defined) what happens if db returns string with number greater than max int?

What means casting to int? Why we need that? IMO a more serious problem are some big sites raising the max int(10) sequence value (logs tables, backup and restore...). Eloy Lafuente (stronk7) 19:35, 6 May 2008 (CDT)
well, some code (like modedit) uses is_int() on results from insert_report() which was was breaking badly when I thied to remove the (int) casting from insert_record() Petr Škoda (škoďák)

Do we have to use array_values() on $params array in order to re-key the array when using "?" in query?

(Status: Open - Severity: Not Critical - Bug: not defined)

It looks like pdo needs that [1]

yes we must do that because the keys must be 0,1,3,... in some drivers Petr Škoda (škoďák)

DB layer functional tests

(Status: In progress - Severity: Critical - Bug: MDL-19057)

reading the comments in php manual it seems like we need a big battery of unit tests to verify everything works as expected

100% agree. For XMLDB stuff, for example... I've more that "custom" tests built in the XMLDBEditor. And it only covers a few DDL commands. I guess we'll need at least.... 100 tests for good dmllib testing. Eloy Lafuente (stronk7) 19:39, 7 May 2008 (CDT)

persistent connections

(Status: Open - Severity: Not Critical - Bug: not defined)

should we limit persistent connections only for simple scripts like file.php and theme stuff? maybe this could make persistent connections more reliable. it could be implemented as some define before require config.php

I would vote to include that define (CAN_USE_PERSISTENT_CONNECTION) in some files, agree. But will create one $CFG->experimentwithpersistentconnections (config-dist.php) to be able to play with it in the safe side. I remember tons of headaches with persistent connections in Moodle early days (due to drivers implementation, mainly). Eloy Lafuente (stronk7) 19:39, 7 May 2008 (CDT)

old mysql driver

(Status: Open - Severity: Not Critical - Bug: not defined)

should we deprecate native mysql driver and use mysqli or pdo:mysql instead?

+1 Eloy Lafuente (stronk7) 18:36, 5 May 2009 (UTC)
we can remove it now completely imo Petr Škoda (škoďák)

ADOdb Insert_ID() function under MSSQL, using placeholders doesn't work

(Status: Closed - Severity: Critical - Bug: MDL-14886)

Problem: Queries using placeholders under MSSQL are executed by one sp_executesql() procedure call. In MSSQL procedures, triggers are executed into new scopes (like "shells"), so the Insert_ID() function (internally usind SCOPE_IDENTITY()) doesn't work at all, because the insert has been executed in another scope.

Solution: Patch ADOdb driver so, each time one INSERT is going to be executed by sp_executesql(), we'll add one SCOPE_IDENTITY() in the same procedure execution (that way, both the insert and the identity will be in the same scope). Once executed, return the value of the identity by the standard Insert_ID() function. BC compatible 100% with current code if implemented that way.

+1 to stop using adodb and emulate bound params if needed -like in other drivers