Conditions for Casts to Polygon is empty, contains more than one  LineString , or contains other geometry types, an ER_INVALID_CAST_TO_GEOMETRY  error occurs. These conditions apply when the cast result type is  Polygon : 2242 •If the expression to cast is a well-formed geometry of type  GeometryCollection  containing only a single  Polygon , the function result is that  Polygon . If the expression is empty, contains more •If the expression to cast is a well-formed geometry of type  MultiPolygon  containing a single Polygon , the function result is that  Polygon . If the expression contains more than one  Polygon , an  ER_INVALID_CAST_TO_GEOMETRY  error occurs. •If the expression to cast is a well-formed geometry of type  MultiLineString  where all elements are rings, the function result is a  Polygon  with the first  LineString  as outer ring and any additional  LineString  values as inner rings. If any element of the expression is not a ring, an  ER_INVALID_CAST_TO_GEOMETRY  error occurs. If any ring is not in the correct order (the exterior ring must be counter-clockwise, interior rings must be clockwise), an ER_INVALID_CAST_POLYGON_RING_DIRECTION  error occurs. •If the expression to cast is a well-formed geometry of type  Polygon , the function result is that Polygon . •If the expression to cast is a well-formed geometry of type  LineString  that is a ring (that is, the start and end points are the same), the function result is a  Polygon  with an outer ring consisting of the points of the  LineString  in the same order. If the expression is not a ring, an ER_INVALID_CAST_TO_GEOMETRY  error occurs. If the ring is not in the correct order (the exterior ring must be counter-clockwise), an  ER_INVALID_CAST_POLYGON_RING_DIRECTION  error occurs. •If the expression to cast is a well-formed geometry of type other than  LineString , Polygon ,  MultiPoint ,  MultiLineString , or  GeometryCollection , an ER_INVALID_CAST_TO_GEOMETRY  error occurs. Conditions for Casts to Polygon