diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,7 @@
+## 0.2.1
+
+* Work around incorrect test for header-file definition of MYSQL_TYPE_JSON (#45 and 51464fa)
+
 ## 0.2.0.1
 
 * Make connection finalizer thread safe (#28).
diff --git a/Database/MySQL/Base/Types.hsc b/Database/MySQL/Base/Types.hsc
--- a/Database/MySQL/Base/Types.hsc
+++ b/Database/MySQL/Base/Types.hsc
@@ -69,6 +69,15 @@
 type MYSQL_ROW_OFFSET = Ptr MYSQL_ROWS
 type MyBool = CChar
 
+-- "mysql.h" defines the `MYSQL_TYPE_...` symbols as values of an enumeration,
+-- not as preprocessor symbols.  Therefore we can't test for the presence of
+-- `MYSQL_TYPE_JSON` using `#ifdef` or `#if defined()`, yet it is not available
+-- in all versions of MySQL and MariaDB.  Although this is very unsatisfactory,
+-- we have little alternative but to define it here.
+--
+mysql_type_json :: Int
+mysql_type_json = 245
+
 -- | Column types supported by MySQL.
 data Type = Decimal
           | Tiny
@@ -132,9 +141,7 @@
       , ((#const MYSQL_TYPE_VAR_STRING), VarString)
       , ((#const MYSQL_TYPE_STRING), String)
       , ((#const MYSQL_TYPE_GEOMETRY), Geometry)
-#if defined(MYSQL_TYPE_JSON)
-      , ((#const MYSQL_TYPE_JSON), Json)
-#endif
+      , (mysql_type_json, Json)
       ]
 
 -- | A description of a field (column) of a table.
diff --git a/mysql.cabal b/mysql.cabal
--- a/mysql.cabal
+++ b/mysql.cabal
@@ -1,5 +1,5 @@
 name:           mysql
-version:        0.2.0.1
+version:        0.2.1
 homepage:       https://github.com/paul-rouse/mysql
 bug-reports:    https://github.com/paul-rouse/mysql/issues
 synopsis:       A low-level MySQL client library.
