Mysql – How to detect JSON data type support in MariaDB/MySQL

jsonmariadbMySQL

My first thought was to check server version but it is not the nicest solution.
Is there something like PHP's function_exists() in mysql?

I'd like to detect JSON_EXTRACT() or the JSON data type: CREATE TABLE t1 (jdoc JSON);

Thank you.

Best Answer

I don't think there is any such feature in MariaDB or MySQL themselves at the moment (MariaDB 10.3, MySQL 5.7, 8.0).

So the only way I can imagine actually detecting support for specific data types and built-in functions on-the-fly would be to try using the data type or funtion, and then catching the exception, if any.

It's also possible that certain software libraries can give you a hint as to what features the underlying RDBMS can offer. If so, this is probably done by storing a list of features associated with each RDBMS version inside the software library.