Same code with version for MySQL:

    else if ( MATCH(key, "subject") ) {
        _append_join(value->table, _subjectfield);
        if (MATCH(db_params.driver, "postgresql")) {
            _append_sort(value->order, "UPPER(COALESCE(sortfield, '')) 
COLLATE\"C\"", reverse);
        } else if (MATCH(db_params.driver, "mysql")) {
            _append_sort(value->order, "UPPER(COALESCE(sortfield, '')) COLLATE 
latin1_general_ci", reverse);
        } else {
            _append_sort(value->order, "UPPER(COALESCE(sortfield, ''))", 
reverse);
        }
        (*idx)++;
    } 



Понедельник,  5 августа 2013, 19:22 +04:00 от ". ." <talanc...@mail.ru>:
>IMAP sort requires input string collation according to the i;unicode-casemap, 
>which describes string conversion to "titlecased
   canonicalized UTF-8".
>Conversion consists of sequential conversion of string's unicode codepoints to 
>"titlecase property" (which is normally the same as the
              uppercase property according to RFC).
>This conversion shouldn't be locale-dependant, so I came up with this fix 
>(works with PostgreSQL, hasn't been tested with other dbs):
>
>    else if ( MATCH(key, "subject") ) {
>        _append_join(value->table, "subjectfield");
>        _append_sort(value->order, "UPPER(COALESCE(sortfield, '')) 
>COLLATE\"C\"", reverse);
>        (*idx)++;
>    }
>
>COLLATE "C" is necessary because of locale issues (database could be created 
>with different locales, and PostgreSQL's sorting depends on the initial 
>locale).
>
>It works fine except that null strings won't sort correctly in reversed order 
>(they mess with empty strings).
>_______________________________________________
>Dbmail-dev mailing list
>Dbmail-dev@dbmail.org
>http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev
>


-- 
. .
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev

Reply via email to