How the IsEmpty() function works in Mariadb?

The IsEmpty() function is a spatial function that returns 1 if the geometry argument is an empty geometry collection, or 0 otherwise.

Posted on

The MariaDB IsEmpty() function is used to determine if a specified geometry is empty. This function is particularly useful in geographic information systems (GIS) where it’s necessary to verify if a geometry contains any points.


The syntax for the IsEmpty() function in MariaDB is as follows:

  • geometry is the geometry instance to be checked.

the IsEmpty() function is not fully implemented by MariaDB or MySQL.

Since MariaDB and MySQL do not support GIS EMPTY values such as POINT EMPTY, as implemented it simply returns 1 if the geometry value g is invalid, 0 if it is valid, and NULL if the argument is NULL


Example 1: Non-Empty Geometry

Illustrating the behavior when checking a non-empty geometry:

SELECT IsEmpty(GeomFromText('POINT(1 1)'));

The output for this statement is:


Since the geometry contains a point, the function returns 0.

Example 2: Empty Geometry

To demonstrate checking an empty geometry:

SELECT IsEmpty(GeomFromText('POINT EMPTY'));

The output for this statement is:

| IsEmpty(GeomFromText('POINT EMPTY')) |
|                                 NULL |

MariaDB does not support EMPTY, so it returns NULL.

Example 3: Invalid Geometry

Showing the result when checking an invalid geometry:

SELECT IsEmpty(GeomFromText('INVALID'));

The output for this statement is:

| IsEmpty(GeomFromText('INVALID')) |
|                             NULL |

The function returns NULL due to the invalid geometry.

Below are a few functions related to the MariaDB IsEmpty() function:

  • MariaDB ST_IsEmpty() function is used to check if a given spatial value is empty according to the SQL/MM standard.
  • MariaDB GeomFromText() function is used to create a geometry instance from a string.


The IsEmpty() function in MariaDB is an essential tool for working with spatial data within a database. It allows for easy identification of empty geometries, ensuring proper handling and analysis in GIS applications. Understanding how to use this function can greatly aid in the management of spatial-related data and ensure accurate processing and storage of geometric information.