SQL query to MariaDB results in Error in result_fetch(res@ptr, n = n) : embedded nul in string

SQL queries to MariaDB may result in the following error

Error in result_fetch(res@ptr, n = n) : embedded nul in string

This one occurs when the text column contains embedded nul in \0.

Reference:Error in result_fetch(res@ptr, n = n) : embedded nul in string · Issue #121 · r-dbi/RMariaDB · GitHub

As a workaround, this column can be cast to BINARY as follows

CASE(col1 as BINARY)