added a comment - - edited
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:
Moodle 2.0 ONWARDS:
Summary:
Before Moodle 2.0 we were applying the dirty hack only to NOT NULL columns, in order to be able to store "empties" in those columns (replacing them by 1-space, converted back to empty when retrieving). We weren't applying the hack to NULL columns at all. This was causing the problem of being impossible to differentiate real NULL and empty values in those columns (all them were stored as NULL).
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.
I have created basic native driver, there are still some problems though:
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.