• Alexander Barkov's avatar
    MDEV-10865 COLLATE keyword doesn't work in PREPARE query · f6989d17
    Alexander Barkov authored
    Fixing applying the COLLATE clause to a parameter caused an error error:
      COLLATION '...' is not valid for CHARACTER SET 'binary'
    
    Fix:
    
    - Changing the collation derivation for a non-prepared Item_param
      to DERIVATION_IGNORABLE.
    
    - Allowing to apply any COLLATE clause to expressions with DERIVATION_IGNORABLE.
      This includes:
        1. A non-prepared Item_param
        2. An explicit NULL
        3. Expressions derived from #1 and #2
    
      For example:
        SELECT ? COLLATE utf8mb_unicode_ci;
        SELECT NULL COLLATE utf8mb_unicode_ci;
        SELECT CONCAT(?) COLLATE utf8mb_unicode_ci;
        SELECT CONCAT(NULL) COLLATE utf8mb_unicode_ci
    
    - Additional change: preserving the collation of an expression when
      the expression gets assigned to a PS parameter and evaluates to SQL NULL.
      Before this change, the collation of the parameter was erroneously set
      to &my_charset_binary.
    
    - Additional change: removing the multiplication to mbmaxlen from the
      fix_char_length_ulonglong() argument, because the multiplication already
      happens inside fix_char_length_ulonglong().
      This fixes a too large column size created for a COLLATE clause.
    f6989d17
item.h 264 KB