|
About DIRTY HACK (1-space hack) before 2.0 and 2.0 onwards
(from comments also in the driver: http://cvs.moodle.org/moodle/lib/dml/oci_native_moodle_database.php?view=markup): BEFORE Moodle 2.0: // For Oracle DB, empty strings are converted to NULLs in DB // and this breaks a lot of NOT NULL columns currenty Moodle. In the future it's // planned to move some of them to NULL, if they must accept empty values and this // piece of code will become less and less used. But, for now, we need it. // What we are going to do is to examine all the data being inserted and if it's // an empty string (NULL for Oracle) and the field is defined as NOT NULL, we'll modify // such data in the best form possible ("0" for booleans and numbers and " " for the // rest of strings. It isn't optimal, but the only way to do so. // In the oppsite, when retrieving records from Oracle, we'll decode " " back to // empty strings to allow everything to work properly. DIRTY HACK. Moodle 2.0 ONWARDS: // Before Moodle 2.0, we only used to apply this DIRTY HACK to NOT NULL columns, as // stated above, but it causes one problem in NULL columns where both empty strings // and real NULLs are stored as NULLs, being impossible to diferentiate them when // being retrieved from DB. // // So, starting with Moodle 2.0, we are going to apply the DIRTY HACK to all the // CHAR/CLOB columns no matter of their nullability. That way, when retrieving // NULLABLE fields we'll get proper empties and NULLs diferentiated, so we'll be able // to rely in NULL/empty/content contents without problems, until now that wasn't // possible at all. // // No breackage with old data is expected as long as at the time of writing this // (20090922) all the current uses of both sql_empty() and sql_isempty() has been // revised in 2.0 and all them were being performed against NOT NULL columns, // where nothing has changed (the DIRTY HACK was already being applied). Summary: To solve this problem, starting with Moodle 2.0, we are going to apply the dirty hack to NULL columns too. That way we'll have both values (NULL and empty) properly separated in the DB, making NULL columns to work exactly like NOT NULL ones were working before Moodle 2.0 with the extra of differentiating NULLs correctly (that didn't worked in 1.9.x at all). Until today all the uses of the sql_empty() and sql_isempty() functions that we have done are against NOT NULL column (their behaviour doesn't change at all in 2.0), so nothing will break with the change. Only NEW uses of those functions against NULL columns will return accurate results, properly differentiating NULLs and empties. At the same time, this makes the HACK itself and the xxx_empty() functions really simpler, because they will be supporting all the char/clob columns, without NULL/NOT NULL distinctions at all. Note: I've reviewed all those uses in core, just a dozen, and all them are against NOT NULL columns or properly covered with and extra NOT IS NULL condition. So, possible values will be:
For NOT NULL columns (same behaviour than before 2.0):
For NULL columns (new behaviour in 2.0):
Comments:
CLOB/BLOB support added
Transactions support added. Also have committed the dirty hack change commented above in case anybody wants to take a look to it (easily reversible if needed, I hope no Ciao Modified the sql_generator (base) so, any empty default passed to xmldb stuff will generate the proper "empty" default to be used, aka, oracle will have proper 1-whitespace defaults when xmldb requires it in field specs. The rest will continue having real empties. Rely on $default_for_char property (same value than $DB->sql_empty(), btw).
Just confirmed Oracle temporary tables are always global while the other big-3 use them in a local way (per session). Need to imagine some workaround for this. Tomorrow (hopefully the moodle_temptables thing will help once more, let's see).
Limit temp table names to something shorter than the current limit (say 20 chars, instead of 30), and then have the oracle driver use $prefix = $CFG->prefix . $ninerandomcharsfromsessinonid . '_'; as the prefix for temp tables.
Or something like that. temp tables support added by using the moodle_temptables stuff, where we change their names internally. Seems to be working ok (passing tests at least).
Added support for DB locking (via PL/SQL package).
Allow multiple connections: - fix connection settings and use oci_new_connect()
|
|||||||||||||||||||||||||||||||||||||||||||||||||
1/ enum support - solution could be to remove all enum support from all drivers and use varchars instead
2/ lob and blob support - there are some unknown problems when binding params, tests are failing for now
3/ sql_bitor() and sql_bitxor() do not support bound params - probably we will have to use user functions
4/ sql_ilike() - again probably solvable by user functions
5/ one space hack handling in text fields seems inconsistent - need detailed review
6/ db session not supported - missing locking code, will probably require http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_lock2.htm#999576
7/ there are several reports in text=varchar comparison problems - needs code review
8/ only oracle 10 supported - will need several workarounds and testing if we want to support 9.2
9/ somebody has to test Oracle with Moodle 2.0dev regularly - there might be many new regressions in the code added during the last year (empty strings, text comparisons, from dual, etc.)
Known problems (oracle 10 only, no extensive testing) can be probably solved in 14 days. The result should be more reliable than to 1.9.x, provided somebody steps up and starts testing/developing/reporting problems related to Oracle databases.