Details
-
Bug
-
Status: In Review (View Workflow)
-
Critical
-
Resolution: Unresolved
-
10.11, 11.4, 11.8.9
-
Linux x86_64, MariaDB 11.8.9 binary distribution
-
Unexpected results
Description
In non-strict SQL mode, AES_ENCRYPT() with an invalid encryption mode returns NULL in a SELECT DISTINCT query, but an equivalent UNION query returns an empty binary string.
The difference reproduces using the native mariadb command-line client. No tables are required.
Reproducer:
SET SESSION sql_mode = '';
|
|
|
SELECT DISTINCT AES_ENCRYPT('x', 'k', '', 'hkdf') AS col1;
|
|
|
SELECT AES_ENCRYPT('x', 'k', '', 'hkdf') AS col1
|
UNION
|
SELECT AES_ENCRYPT('x', 'k', '', 'hkdf') AS col1;
|
Actual result on 11.8.9-MariaDB:
The SELECT DISTINCT query returns one row containing NULL:
col1
|
NULL
|
The UNION query returns one row containing an empty binary string instead of NULL.
In MariaDB, the fourth argument of AES_ENCRYPT() specifies the encryption mode. Although 'hkdf' is not a valid encryption mode, using the same fixed arguments in equivalent SELECT DISTINCT and UNION queries should not change NULL into an empty string.